return to first page linux journal archive
keywordscontents

Listing 3. Option Handling Code

COMMAND='\$\{${pathvar}\}${sep}${dirname}'
                            # default
pathvar=PATH                # default
[ -n "$opt_f" ] && COMMAND='${dirname}${sep}\$${pathvar}'
[ -n "$opt_p" ] && pathvar=$opt_p
# check to see if we're defining a new 
# pathvar. If so we clear the separator so as to
# avoid leading or trailing :'s
sep=:                       # default
eval tmp=\$$pathvar
[ "$tmp" = "" ] && sep=
dirname=$1