45.13 Save Disk Space and Programming: Multiple Names for a Program
you might want to write just one program and make links (18.4 , 18.3 ) to it instead. The program can find the name you called it with and, through case or test commands, work in different ways. For instance, the Berkeley UNIX commands ex , vi , view , edit , and others are all links to the same executable file. This takes less disk space and makes maintenance easier. It's usually only sensible when most of the code is the same in each program. If the program is full of name tests and lots of separate code, this technique may be more trouble than it's worth. Depending on how the script program is called, this name can be
a simple
relative pathname like case "$0" in *
You might also want to use
basename
(45.18
)
to strip off any leading pathname and store the cleaned-up myname=`basename $0` ... case "$myname" in ... echo "$myname: aborting; error in xxxxxx" 1>&2 ... - |
|