Like the alias assignment, write your code in a file that can be sourced.
Put your code in a file called bash-fun.sh. When you are ready to test the function definitions, source the file.
. bash-fun.sh
Remember to documentation in your code.
vfile does the following :
If file is a regular file and is readable Then If file-name is not a symbolic link. then display the file-name provided. return with a code of 0 else display the file-name provided. return with a code of 1 end-if else return with a code of 2 end-if
If invoked with no arguments, then call vfile function with no arguments.
If invoked with arguments, then call vfile with the 1st argument.
Once vfile has validated the filename, copy the file to $HOME/Backup directory. When you copy the file, use the tstamp alias to generate a time stamp, add append the time-stamp as an extension to the file-name.
Put you tstamp definition in the assignment shell script, so it is activated when the script is run.
Backup should be designed to look for a file in the current directory, so Backup should not accept path information in the filename specified.
Backup does the following :
Call vfile. Remember, vfile will call getname and then check for files existence. Assign the returned file-name to a local variable. If vfile does not output a file-name, you can still assign the null output to the variable. Use the return code to judge success. If return code is 0 then copy the file to $HOME/Backup appending the time-stamp generated by tstamp. else if return code is 1 copy the file-name to $HOME/Backup appending the timestamp. You can use the Backup alias as a starting point of coding. But use the cp -P option. This will copy the symbolic link, not the actual file. See man cp else Inform user the file-name was not valid. end-if.