"Fossies" - the Fresh Open Source Software Archive

Member "dbg-2.15.5/build/shtool" (2 Aug 2006, 39388 Bytes) of package /linux/www/old/dbg-2.15.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 ##
    3 ##  GNU shtool -- The GNU Portable Shell Tool
    4 ##  Copyright (c) 1994-2005 Ralf S. Engelschall <rse@engelschall.com>
    5 ##
    6 ##  See http://www.gnu.org/software/shtool/ for more information.
    7 ##  See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
    8 ##
    9 ##  Version:  2.0.2 (15-Jun-2005)
   10 ##  Contents: 4/19 available modules
   11 ##
   12 
   13 ##
   14 ##  This program is free software; you can redistribute it and/or modify
   15 ##  it under the terms of the GNU General Public License as published by
   16 ##  the Free Software Foundation; either version 2 of the License, or
   17 ##  (at your option) any later version.
   18 ##
   19 ##  This program is distributed in the hope that it will be useful,
   20 ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
   21 ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   22 ##  General Public License for more details.
   23 ##
   24 ##  You should have received a copy of the GNU General Public License
   25 ##  along with this program; if not, write to the Free Software
   26 ##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   27 ##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
   28 ##
   29 ##  NOTICE: Given that you include this file verbatim into your own
   30 ##  source tree, you are justified in saying that it remains separate
   31 ##  from your package, and that this way you are simply just using GNU
   32 ##  shtool. So, in this situation, there is no requirement that your
   33 ##  package itself is licensed under the GNU General Public License in
   34 ##  order to take advantage of GNU shtool.
   35 ##
   36 
   37 ##
   38 ##  Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]
   39 ##
   40 ##  Available commands:
   41 ##    echo       Print string with optional construct expansion
   42 ##    install    Install a program, script or datafile
   43 ##    mkdir      Make one or more directories
   44 ##    path       Deal with program paths
   45 ##
   46 ##  Not available commands (because module was not built-in):
   47 ##    mdate      Pretty-print modification time of a file or dir
   48 ##    table      Pretty-print a field-separated list as a table
   49 ##    prop       Display progress with a running propeller
   50 ##    move       Move files with simultaneous substitution
   51 ##    mkln       Make link with calculation of relative paths
   52 ##    mkshadow   Make a shadow tree through symbolic links
   53 ##    fixperm    Fix file permissions inside a source tree
   54 ##    rotate     Logfile rotation
   55 ##    tarball    Roll distribution tarballs
   56 ##    subst      Apply sed(1) substitution operations
   57 ##    platform   Platform Identification Utility
   58 ##    arx        Extended archive command
   59 ##    slo        Separate linker options by library class
   60 ##    scpp       Sharing C Pre-Processor
   61 ##    version    Maintain a version information file
   62 ##
   63 
   64 if [ $# -eq 0 ]; then
   65     echo "$0:Error: invalid command line" 1>&2
   66     echo "$0:Hint:  run \`$0 -h' for usage" 1>&2
   67     exit 1
   68 fi
   69 if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
   70     echo "This is GNU shtool, version 2.0.2 (15-Jun-2005)"
   71     echo "Copyright (c) 1994-2005 Ralf S. Engelschall <rse@engelschall.com>"
   72     echo "Report bugs to <bug-shtool@gnu.org>"
   73     echo ''
   74     echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
   75     echo ''
   76     echo 'Available global <options>:'
   77     echo '  -v, --version   display shtool version information'
   78     echo '  -h, --help      display shtool usage help page (this one)'
   79     echo '  -d, --debug     display shell trace information'
   80     echo '  -r, --recreate  recreate this shtool script via shtoolize'
   81     echo ''
   82     echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
   83     echo '  echo     [-n|--newline] [-e|--expand] [<string> ...]'
   84     echo '  install  [-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy]'
   85     echo '           [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>]'
   86     echo '           [-o|--owner <owner>] [-g|--group <group>] [-e|--exec'
   87     echo '           <sed-cmd>] <file> [<file> ...] <path>'
   88     echo '  mkdir    [-t|--trace] [-f|--force] [-p|--parents] [-m|--mode'
   89     echo '           <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir>'
   90     echo '           [<dir> ...]'
   91     echo '  path     [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename]'
   92     echo '           [-m|--magic] [-p|--path <path>] <str> [<str> ...]'
   93     echo ''
   94     echo 'Not available <cmd-name> (because module was not built-in):'
   95     echo '  mdate    [-n|--newline] [-z|--zero] [-s|--shorten] [-d|--digits]'
   96     echo '           [-f|--field-sep <str>] [-o|--order <spec>] <path>'
   97     echo '  table    [-F|--field-sep <sep>] [-w|--width <width>] [-c|--columns'
   98     echo '           <cols>] [-s|--strip <strip>] <str><sep><str>...'
   99     echo '  prop     [-p|--prefix <str>]'
  100     echo '  move     [-v|--verbose] [-t|--trace] [-e|--expand] [-p|--preserve]'
  101     echo '           <src-file> <dst-file>'
  102     echo '  mkln     [-t|--trace] [-f|--force] [-s|--symbolic] <src-path>'
  103     echo '           [<src-path> ...] <dst-path>'
  104     echo '  mkshadow [-v|--verbose] [-t|--trace] [-a|--all] <src-dir> <dst-dir>'
  105     echo '  fixperm  [-v|--verbose] [-t|--trace] <path> [<path> ...]'
  106     echo '  rotate   [-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files'
  107     echo '           <count>] [-s|--size <size>] [-c|--copy] [-r|--remove]'
  108     echo '           [-a|--archive-dir <dir>] [-z|--compress [<tool>:]<level>]'
  109     echo '           [-b|--background] [-d|--delay] [-p|--pad <len>] [-m|--mode'
  110     echo '           <mode>] [-o|--owner <owner>] [-g|--group <group>] [-M|--migrate'
  111     echo '           <cmd>] [-P|--prolog <cmd>] [-E|--epilog <cmd>] <file> [...]'
  112     echo '  tarball  [-t|--trace] [-v|--verbose] [-o|--output <tarball>]'
  113     echo '           [-c|--compress <prog>] [-d|--directory <dir>] [-u|--user'
  114     echo '           <user>] [-g|--group <group>] [-e|--exclude <pattern>]'
  115     echo '           <path> [<path> ...]'
  116     echo '  subst    [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning]'
  117     echo '           [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup'
  118     echo '           <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>]'
  119     echo '           [...]'
  120     echo '  platform [-F|--format <format>] [-S|--sep <string>] [-C|--conc'
  121     echo '           <string>] [-L|--lower] [-U|--upper] [-v|--verbose]'
  122     echo '           [-c|--concise] [-n|--no-newline] [-t|--type <type>]'
  123     echo '           [-V|--version] [-h|--help]'
  124     echo '  arx      [-t|--trace] [-C|--command <cmd>] <op> <archive> [<file>'
  125     echo '           ...]'
  126     echo '  slo      [-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib>'
  127     echo '           ...]'
  128     echo '  scpp     [-v|--verbose] [-p|--preserve] [-f|--filter <filter>]'
  129     echo '           [-o|--output <ofile>] [-t|--template <tfile>] [-M|--mark'
  130     echo '           <mark>] [-D|--define <dname>] [-C|--class <cname>]'
  131     echo '           <file> [<file> ...]'
  132     echo '  version  [-l|--language <lang>] [-n|--name <name>] [-p|--prefix'
  133     echo '           <prefix>] [-s|--set <version>] [-e|--edit] [-i|--increase'
  134     echo '           <knob>] [-d|--display <type>] <file>'
  135     echo ''
  136     exit 0
  137 fi
  138 if [ ".$1" = ".-v" ] || [ ".$1" = ".--version" ]; then
  139     echo "GNU shtool 2.0.2 (15-Jun-2005)"
  140     exit 0
  141 fi
  142 if [ ".$1" = ".-r" ] || [ ".$1" = ".--recreate" ]; then
  143     shtoolize -oshtool echo install mkdir path
  144     exit 0
  145 fi
  146 if [ ".$1" = ".-d" ] || [ ".$1" = ".--debug" ]; then
  147     shift
  148     set -x
  149 fi
  150 name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
  151 case "$name" in
  152     echo|install|mkdir|path )
  153         #   implicit tool command selection
  154         tool="$name"
  155         ;;
  156     * )
  157         #   explicit tool command selection
  158         tool="$1"
  159         shift
  160         ;;
  161 esac
  162 arg_spec=""
  163 opt_spec=""
  164 gen_tmpfile=no
  165 
  166 ##
  167 ##  DISPATCH INTO SCRIPT PROLOG
  168 ##
  169 
  170 case $tool in
  171     echo )
  172         str_tool="echo"
  173         str_usage="[-n|--newline] [-e|--expand] [<string> ...]"
  174         arg_spec="0+"
  175         opt_spec="n.e."
  176         opt_alias="n:newline,e:expand"
  177         opt_n=no
  178         opt_e=no
  179         ;;
  180     install )
  181         str_tool="install"
  182         str_usage="[-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy] [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] [-e|--exec <sed-cmd>] <file> [<file> ...] <path>"
  183         arg_spec="1+"
  184         opt_spec="v.t.d.c.C.s.m:o:g:e+"
  185         opt_alias="v:verbose,t:trace,d:mkdir,c:copy,C:compare-copy,s:strip,m:mode,o:owner,g:group,e:exec"
  186         opt_v=no
  187         opt_t=no
  188         opt_d=no
  189         opt_c=no
  190         opt_C=no
  191         opt_s=no
  192         opt_m="0755"
  193         opt_o=""
  194         opt_g=""
  195         opt_e=""
  196         ;;
  197     mkdir )
  198         str_tool="mkdir"
  199         str_usage="[-t|--trace] [-f|--force] [-p|--parents] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir> [<dir> ...]"
  200         arg_spec="1+"
  201         opt_spec="t.f.p.m:o:g:"
  202         opt_alias="t:trace,f:force,p:parents,m:mode,o:owner,g:group"
  203         opt_t=no
  204         opt_f=no
  205         opt_p=no
  206         opt_m=""
  207         opt_o=""
  208         opt_g=""
  209         ;;
  210     path )
  211         str_tool="path"
  212         str_usage="[-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path <path>] <str> [<str> ...]"
  213         gen_tmpfile=yes
  214         arg_spec="1+"
  215         opt_spec="s.r.d.b.m.p:"
  216         opt_alias="s:suppress,r:reverse,d:dirname,b:basename,m:magic,p:path"
  217         opt_s=no
  218         opt_r=no
  219         opt_d=no
  220         opt_b=no
  221         opt_m=no
  222         opt_p="$PATH"
  223         ;;
  224     -* )
  225         echo "$0:Error: unknown option \`$tool'" 2>&1
  226         echo "$0:Hint:  run \`$0 -h' for usage" 2>&1
  227         exit 1
  228         ;;
  229     * )
  230         echo "$0:Error: unknown command \`$tool'" 2>&1
  231         echo "$0:Hint:  run \`$0 -h' for usage" 2>&1
  232         exit 1
  233         ;;
  234 esac
  235 
  236 ##
  237 ##  COMMON UTILITY CODE
  238 ##
  239 
  240 #   commonly used ASCII values
  241 ASC_TAB="   "
  242 ASC_NL="
  243 "
  244 
  245 #   determine name of tool
  246 if [ ".$tool" != . ]; then
  247     #   used inside shtool script
  248     toolcmd="$0 $tool"
  249     toolcmdhelp="shtool $tool"
  250     msgprefix="shtool:$tool"
  251 else
  252     #   used as standalone script
  253     toolcmd="$0"
  254     toolcmdhelp="sh $0"
  255     msgprefix="$str_tool"
  256 fi
  257 
  258 #   parse argument specification string
  259 eval `echo $arg_spec |\
  260       sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'`
  261 
  262 #   parse option specification string
  263 eval `echo h.$opt_spec |\
  264       sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
  265 
  266 #   parse option alias string
  267 eval `echo h:help,$opt_alias |\
  268       sed -e 's/-/_/g' -e 's/\([a-zA-Z0-9]\):\([^,]*\),*/opt_ALIAS_\2=\1;/g'`
  269 
  270 #   interate over argument line
  271 opt_PREV=''
  272 while [ $# -gt 0 ]; do
  273     #   special option stops processing
  274     if [ ".$1" = ".--" ]; then
  275         shift
  276         break
  277     fi
  278 
  279     #   determine option and argument
  280     opt_ARG_OK=no
  281     if [ ".$opt_PREV" != . ]; then
  282         #   merge previous seen option with argument
  283         opt_OPT="$opt_PREV"
  284         opt_ARG="$1"
  285         opt_ARG_OK=yes
  286         opt_PREV=''
  287     else
  288         #   split argument into option and argument
  289         case "$1" in
  290             --[a-zA-Z0-9]*=*)
  291                 eval `echo "x$1" |\
  292                       sed -e 's/^x--\([a-zA-Z0-9-]*\)=\(.*\)$/opt_OPT="\1";opt_ARG="\2"/'`
  293                 opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'`
  294                 eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
  295                 ;;
  296             --[a-zA-Z0-9]*)
  297                 opt_OPT=`echo "x$1" | cut -c4-`
  298                 opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'`
  299                 eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
  300                 opt_ARG=''
  301                 ;;
  302             -[a-zA-Z0-9]*)
  303                 eval `echo "x$1" |\
  304                       sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
  305                           -e 's/";\(.*\)$/"; opt_ARG="\1"/'`
  306                 ;;
  307             -[a-zA-Z0-9])
  308                 opt_OPT=`echo "x$1" | cut -c3-`
  309                 opt_ARG=''
  310                 ;;
  311             *)
  312                 break
  313                 ;;
  314         esac
  315     fi
  316 
  317     #   eat up option
  318     shift
  319 
  320     #   determine whether option needs an argument
  321     eval "opt_MODE=\$opt_MODE_${opt_OPT}"
  322     if [ ".$opt_ARG" = . ] && [ ".$opt_ARG_OK" != .yes ]; then
  323         if [ ".$opt_MODE" = ".:" ] || [ ".$opt_MODE" = ".+" ]; then
  324             opt_PREV="$opt_OPT"
  325             continue
  326         fi
  327     fi
  328 
  329     #   process option
  330     case $opt_MODE in
  331         '.' )
  332             #   boolean option
  333             eval "opt_${opt_OPT}=yes"
  334             ;;
  335         ':' )
  336             #   option with argument (multiple occurances override)
  337             eval "opt_${opt_OPT}=\"\$opt_ARG\""
  338             ;;
  339         '+' )
  340             #   option with argument (multiple occurances append)
  341             eval "opt_${opt_OPT}=\"\$opt_${opt_OPT}\${ASC_NL}\$opt_ARG\""
  342             ;;
  343         * )
  344             echo "$msgprefix:Error: unknown option: \`$opt_OPT'" 1>&2
  345             echo "$msgprefix:Hint:  run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
  346             exit 1
  347             ;;
  348     esac
  349 done
  350 if [ ".$opt_PREV" != . ]; then
  351     echo "$msgprefix:Error: missing argument to option \`$opt_PREV'" 1>&2
  352     echo "$msgprefix:Hint:  run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
  353     exit 1
  354 fi
  355 
  356 #   process help option
  357 if [ ".$opt_h" = .yes ]; then
  358     echo "Usage: $toolcmdhelp $str_usage"
  359     exit 0
  360 fi
  361 
  362 #   complain about incorrect number of arguments
  363 case $arg_MODE in
  364     '=' )
  365         if [ $# -ne $arg_NUMS ]; then
  366             echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2
  367             echo "$msgprefix:Hint:  run \`$toolcmd -h' or \`man shtool' for details" 1>&2
  368             exit 1
  369         fi
  370         ;;
  371     '+' )
  372         if [ $# -lt $arg_NUMS ]; then
  373             echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2
  374             echo "$msgprefix:Hint:  run \`$toolcmd -h' or \`man shtool' for details" 1>&2
  375             exit 1
  376         fi
  377         ;;
  378 esac
  379 
  380 #   establish a temporary file on request
  381 if [ ".$gen_tmpfile" = .yes ]; then
  382     #   create (explicitly) secure temporary directory
  383     if [ ".$TMPDIR" != . ]; then
  384         tmpdir="$TMPDIR"
  385     elif [ ".$TEMPDIR" != . ]; then
  386         tmpdir="$TEMPDIR"
  387     else
  388         tmpdir="/tmp"
  389     fi
  390     tmpdir="$tmpdir/.shtool.$$"
  391     ( umask 077
  392       rm -rf "$tmpdir" >/dev/null 2>&1 || true
  393       mkdir  "$tmpdir" >/dev/null 2>&1
  394       if [ $? -ne 0 ]; then
  395           echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2
  396           exit 1
  397       fi
  398     )
  399 
  400     #   create (implicitly) secure temporary file
  401     tmpfile="$tmpdir/shtool.tmp"
  402     touch "$tmpfile"
  403 fi
  404 
  405 #   utility function: map string to lower case
  406 util_lower () {
  407     echo "$1" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
  408 }
  409 
  410 #   utility function: map string to upper case
  411 util_upper () {
  412     echo "$1" | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  413 }
  414 
  415 #   cleanup procedure
  416 shtool_exit () {
  417     rc="$1"
  418     if [ ".$gen_tmpfile" = .yes ]; then
  419         rm -rf "$tmpdir" >/dev/null 2>&1 || true
  420     fi
  421     exit $rc
  422 }
  423 
  424 ##
  425 ##  DISPATCH INTO SCRIPT BODY
  426 ##
  427 
  428 case $tool in
  429 
  430 echo )
  431     ##
  432     ##  echo -- Print string with optional construct expansion
  433     ##  Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
  434     ##
  435 
  436     text="$*"
  437 
  438     #   check for broken escape sequence expansion
  439     seo=''
  440     bytes=`echo '\1' | wc -c | awk '{ printf("%s", $1); }'`
  441     if [ ".$bytes" != .3 ]; then
  442         bytes=`echo -E '\1' | wc -c | awk '{ printf("%s", $1); }'`
  443         if [ ".$bytes" = .3 ]; then
  444             seo='-E'
  445         fi
  446     fi
  447 
  448     #   check for existing -n option (to suppress newline)
  449     minusn=''
  450     bytes=`echo -n 123 2>/dev/null | wc -c | awk '{ printf("%s", $1); }'`
  451     if [ ".$bytes" = .3 ]; then
  452         minusn='-n'
  453     fi
  454 
  455     #   determine terminal bold sequence
  456     term_bold=''
  457     term_norm=''
  458     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[Bb]'`" != . ]; then
  459         case $TERM in
  460             #   for the most important terminal types we directly know the sequences
  461             xterm|xterm*|vt220|vt220*)
  462                 term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
  463                 term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
  464                 ;;
  465             vt100|vt100*|cygwin)
  466                 term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
  467                 term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
  468                 ;;
  469             #   for all others, we try to use a possibly existing `tput' or `tcout' utility
  470             * )
  471                 paths=`echo $PATH | sed -e 's/:/ /g'`
  472                 for tool in tput tcout; do
  473                     for dir in $paths; do
  474                         if [ -r "$dir/$tool" ]; then
  475                             for seq in bold md smso; do # 'smso' is last
  476                                 bold="`$dir/$tool $seq 2>/dev/null`"
  477                                 if [ ".$bold" != . ]; then
  478                                     term_bold="$bold"
  479                                     break
  480                                 fi
  481                             done
  482                             if [ ".$term_bold" != . ]; then
  483                                 for seq in sgr0 me rmso init reset; do # 'reset' is last
  484                                     norm="`$dir/$tool $seq 2>/dev/null`"
  485                                     if [ ".$norm" != . ]; then
  486                                         term_norm="$norm"
  487                                         break
  488                                     fi
  489                                 done
  490                             fi
  491                             break
  492                         fi
  493                     done
  494                     if [ ".$term_bold" != . ] && [ ".$term_norm" != . ]; then
  495                         break;
  496                     fi
  497                 done
  498                 ;;
  499         esac
  500         if [ ".$term_bold" = . ] || [ ".$term_norm" = . ]; then
  501             echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
  502             term_bold=''
  503             term_norm=''
  504         fi
  505     fi
  506 
  507     #   determine user name
  508     username=''
  509     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[uUgG]'`" != . ]; then
  510         username="`(id -un) 2>/dev/null`"
  511         if [ ".$username" = . ]; then
  512             str="`(id) 2>/dev/null`"
  513             if [ ".`echo $str | grep '^uid[     ]*=[    ]*[0-9]*('`" != . ]; then
  514                 username=`echo $str | sed -e 's/^uid[   ]*=[    ]*[0-9]*(//' -e 's/).*$//'`
  515             fi
  516             if [ ".$username" = . ]; then
  517                 username="$LOGNAME"
  518                 if [ ".$username" = . ]; then
  519                     username="$USER"
  520                     if [ ".$username" = . ]; then
  521                         username="`(whoami) 2>/dev/null |\
  522                                    awk '{ printf("%s", $1); }'`"
  523                         if [ ".$username" = . ]; then
  524                             username="`(who am i) 2>/dev/null |\
  525                                        awk '{ printf("%s", $1); }'`"
  526                             if [ ".$username" = . ]; then
  527                                 username='unknown'
  528                             fi
  529                         fi
  530                     fi
  531                 fi
  532             fi
  533         fi
  534     fi
  535 
  536     #   determine user id
  537     userid=''
  538     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%U'`" != . ]; then
  539         userid="`(id -u) 2>/dev/null`"
  540         if [ ".$userid" = . ]; then
  541             userid="`(id -u ${username}) 2>/dev/null`"
  542             if [ ".$userid" = . ]; then
  543                 str="`(id) 2>/dev/null`"
  544                 if [ ".`echo $str | grep '^uid[     ]*=[    ]*[0-9]*('`" != . ]; then
  545                     userid=`echo $str | sed -e 's/^uid[     ]*=[    ]*//' -e 's/(.*$//'`
  546                 fi
  547                 if [ ".$userid" = . ]; then
  548                     userid=`(getent passwd ${username}) 2>/dev/null | \
  549                             sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
  550                     if [ ".$userid" = . ]; then
  551                         userid=`grep "^${username}:" /etc/passwd 2>/dev/null | \
  552                                 sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
  553                         if [ ".$userid" = . ]; then
  554                             userid=`(ypcat passwd) 2>/dev/null |
  555                                     grep "^${username}:" | \
  556                                     sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
  557                             if [ ".$userid" = . ]; then
  558                                 userid='?'
  559                             fi
  560                         fi
  561                     fi
  562                 fi
  563             fi
  564         fi
  565     fi
  566 
  567     #   determine (primary) group id
  568     groupid=''
  569     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[gG]'`" != . ]; then
  570         groupid="`(id -g ${username}) 2>/dev/null`"
  571         if [ ".$groupid" = . ]; then
  572             str="`(id) 2>/dev/null`"
  573             if [ ".`echo $str | grep 'gid[  ]*=[    ]*[0-9]*('`" != . ]; then
  574                 groupid=`echo $str | sed -e 's/^.*gid[  ]*=[    ]*//' -e 's/(.*$//'`
  575             fi
  576             if [ ".$groupid" = . ]; then
  577                 groupid=`(getent passwd ${username}) 2>/dev/null | \
  578                          sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
  579                 if [ ".$groupid" = . ]; then
  580                     groupid=`grep "^${username}:" /etc/passwd 2>/dev/null | \
  581                              sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
  582                     if [ ".$groupid" = . ]; then
  583                         groupid=`(ypcat passwd) 2>/dev/null | grep "^${username}:" | \
  584                                  sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
  585                         if [ ".$groupid" = . ]; then
  586                             groupid='?'
  587                         fi
  588                     fi
  589                 fi
  590             fi
  591         fi
  592     fi
  593 
  594     #   determine (primary) group name
  595     groupname=''
  596     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%g'`" != . ]; then
  597         groupname="`(id -gn ${username}) 2>/dev/null`"
  598         if [ ".$groupname" = . ]; then
  599             str="`(id) 2>/dev/null`"
  600             if [ ".`echo $str | grep 'gid[  ]*=[    ]*[0-9]*('`" != . ]; then
  601                 groupname=`echo $str | sed -e 's/^.*gid[    ]*=[    ]*[0-9]*(//' -e 's/).*$//'`
  602             fi
  603             if [ ".$groupname" = . ]; then
  604                 groupname=`(getent group) 2>/dev/null | \
  605                            grep "^[^:]*:[^:]*:${groupid}:" | \
  606                            sed -e 's/:.*$//'`
  607                 if [ ".$groupname" = . ]; then
  608                     groupname=`grep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \
  609                                sed -e 's/:.*$//'`
  610                     if [ ".$groupname" = . ]; then
  611                         groupname=`(ypcat group) 2>/dev/null | \
  612                                    grep "^[^:]*:[^:]*:${groupid}:" | \
  613                                    sed -e 's/:.*$//'`
  614                         if [ ".$groupname" = . ]; then
  615                             groupname='?'
  616                         fi
  617                     fi
  618                 fi
  619             fi
  620         fi
  621     fi
  622 
  623     #   determine host and domain name
  624     hostname=''
  625     domainname=''
  626     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%h'`" != . ]; then
  627         hostname="`(uname -n) 2>/dev/null |\
  628                    awk '{ printf("%s", $1); }'`"
  629         if [ ".$hostname" = . ]; then
  630             hostname="`(hostname) 2>/dev/null |\
  631                        awk '{ printf("%s", $1); }'`"
  632             if [ ".$hostname" = . ]; then
  633                 hostname='unknown'
  634             fi
  635         fi
  636         case $hostname in
  637             *.* )
  638                 domainname=".`echo $hostname | cut -d. -f2-`"
  639                 hostname="`echo $hostname | cut -d. -f1`"
  640                 ;;
  641         esac
  642     fi
  643     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%d'`" != . ]; then
  644         if [ ".$domainname" = . ]; then
  645             if [ -f /etc/resolv.conf ]; then
  646                 domainname="`grep '^[   ]*domain' /etc/resolv.conf | sed -e 'q' |\
  647                              sed -e 's/.*domain//' \
  648                                  -e 's/^[   ]*//' -e 's/^ *//' -e 's/^  *//' \
  649                                  -e 's/^\.//' -e 's/^/./' |\
  650                              awk '{ printf("%s", $1); }'`"
  651                 if [ ".$domainname" = . ]; then
  652                     domainname="`grep '^[   ]*search' /etc/resolv.conf | sed -e 'q' |\
  653                                  sed -e 's/.*search//' \
  654                                      -e 's/^[   ]*//' -e 's/^ *//' -e 's/^  *//' \
  655                                      -e 's/ .*//' -e 's/    .*//' \
  656                                      -e 's/^\.//' -e 's/^/./' |\
  657                                  awk '{ printf("%s", $1); }'`"
  658                 fi
  659             fi
  660         fi
  661     fi
  662 
  663     #   determine current time
  664     time_day=''
  665     time_month=''
  666     time_year=''
  667     time_monthname=''
  668     if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[DMYm]'`" != . ]; then
  669         time_day=`date '+%d'`
  670         time_month=`date '+%m'`
  671         time_year=`date '+%Y' 2>/dev/null`
  672         if [ ".$time_year" = . ]; then
  673             time_year=`date '+%y'`
  674             case $time_year in
  675                 [5-9][0-9]) time_year="19$time_year" ;;
  676                 [0-4][0-9]) time_year="20$time_year" ;;
  677             esac
  678         fi
  679         case $time_month in
  680             1|01) time_monthname='Jan' ;;
  681             2|02) time_monthname='Feb' ;;
  682             3|03) time_monthname='Mar' ;;
  683             4|04) time_monthname='Apr' ;;
  684             5|05) time_monthname='May' ;;
  685             6|06) time_monthname='Jun' ;;
  686             7|07) time_monthname='Jul' ;;
  687             8|08) time_monthname='Aug' ;;
  688             9|09) time_monthname='Sep' ;;
  689               10) time_monthname='Oct' ;;
  690               11) time_monthname='Nov' ;;
  691               12) time_monthname='Dec' ;;
  692         esac
  693     fi
  694 
  695     #   expand special ``%x'' constructs
  696     if [ ".$opt_e" = .yes ]; then
  697         text=`echo $seo "$text" |\
  698               sed -e "s/%B/${term_bold}/g" \
  699                   -e "s/%b/${term_norm}/g" \
  700                   -e "s/%u/${username}/g" \
  701                   -e "s/%U/${userid}/g" \
  702                   -e "s/%g/${groupname}/g" \
  703                   -e "s/%G/${groupid}/g" \
  704                   -e "s/%h/${hostname}/g" \
  705                   -e "s/%d/${domainname}/g" \
  706                   -e "s/%D/${time_day}/g" \
  707                   -e "s/%M/${time_month}/g" \
  708                   -e "s/%Y/${time_year}/g" \
  709                   -e "s/%m/${time_monthname}/g" 2>/dev/null`
  710     fi
  711 
  712     #   create output
  713     if [ .$opt_n = .no ]; then
  714         echo $seo "$text"
  715     else
  716         #   the harder part: echo -n is best, because
  717         #   awk may complain about some \xx sequences.
  718         if [ ".$minusn" != . ]; then
  719             echo $seo $minusn "$text"
  720         else
  721             echo dummy | awk '{ printf("%s", TEXT); }' TEXT="$text"
  722         fi
  723     fi
  724 
  725     shtool_exit 0
  726     ;;
  727 
  728 install )
  729     ##
  730     ##  install -- Install a program, script or datafile
  731     ##  Copyright (c) 1997-2005 Ralf S. Engelschall <rse@engelschall.com>
  732     ##
  733 
  734     #   special case: "shtool install -d <dir> [...]" internally
  735     #   maps to "shtool mkdir -f -p -m 755 <dir> [...]"
  736     if [ "$opt_d" = yes ]; then
  737         cmd="$0 mkdir -f -p -m 755"
  738         if [ ".$opt_o" != . ]; then
  739             cmd="$cmd -o '$opt_o'"
  740         fi
  741         if [ ".$opt_g" != . ]; then
  742             cmd="$cmd -g '$opt_g'"
  743         fi
  744         if [ ".$opt_v" = .yes ]; then
  745             cmd="$cmd -v"
  746         fi
  747         if [ ".$opt_t" = .yes ]; then
  748             cmd="$cmd -t"
  749         fi
  750         for dir in "$@"; do
  751             eval "$cmd $dir" || shtool_exit $?
  752         done
  753         shtool_exit 0
  754     fi
  755 
  756     #   determine source(s) and destination
  757     argc=$#
  758     srcs=""
  759     while [ $# -gt 1 ]; do
  760         srcs="$srcs $1"
  761         shift
  762     done
  763     dstpath="$1"
  764 
  765     #   type check for destination
  766     dstisdir=0
  767     if [ -d $dstpath ]; then
  768         dstpath=`echo "$dstpath" | sed -e 's:/$::'`
  769         dstisdir=1
  770     fi
  771 
  772     #   consistency check for destination
  773     if [ $argc -gt 2 ] && [ $dstisdir = 0 ]; then
  774         echo "$msgprefix:Error: multiple sources require destination to be directory" 1>&2
  775         shtool_exit 1
  776     fi
  777 
  778     #   iterate over all source(s)
  779     for src in $srcs; do
  780         dst=$dstpath
  781 
  782         #   if destination is a directory, append the input filename
  783         if [ $dstisdir = 1 ]; then
  784             dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
  785             dst="$dst/$dstfile"
  786         fi
  787 
  788         #   check for correct arguments
  789         if [ ".$src" = ".$dst" ]; then
  790             echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2
  791             continue
  792         fi
  793         if [ -d "$src" ]; then
  794             echo "$msgprefix:Warning: source \`$src' is a directory - skipped" 1>&2
  795             continue
  796         fi
  797 
  798         #   make a temp file name in the destination directory
  799         dsttmp=`echo $dst |\
  800                 sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \
  801                     -e "s;\$;/#INST@$$#;"`
  802 
  803         #   verbosity
  804         if [ ".$opt_v" = .yes ]; then
  805             echo "$src -> $dst" 1>&2
  806         fi
  807 
  808         #   copy or move the file name to the temp name
  809         #   (because we might be not allowed to change the source)
  810         if [ ".$opt_C" = .yes ]; then
  811             opt_c=yes
  812         fi
  813         if [ ".$opt_c" = .yes ]; then
  814             if [ ".$opt_t" = .yes ]; then
  815                 echo "cp $src $dsttmp" 1>&2
  816             fi
  817             cp $src $dsttmp || shtool_exit $?
  818         else
  819             if [ ".$opt_t" = .yes ]; then
  820                 echo "mv $src $dsttmp" 1>&2
  821             fi
  822             mv $src $dsttmp || shtool_exit $?
  823         fi
  824 
  825         #   adjust the target file
  826         if [ ".$opt_e" != . ]; then
  827             sed='sed'
  828             OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS"
  829             for e
  830             do
  831                 sed="$sed -e '$e'"
  832             done
  833             cp $dsttmp $dsttmp.old
  834             chmod u+w $dsttmp
  835             eval "$sed <$dsttmp.old >$dsttmp" || shtool_exit $?
  836             rm -f $dsttmp.old
  837         fi
  838         if [ ".$opt_s" = .yes ]; then
  839             if [ ".$opt_t" = .yes ]; then
  840                 echo "strip $dsttmp" 1>&2
  841             fi
  842             strip $dsttmp || shtool_exit $?
  843         fi
  844         if [ ".$opt_o" != . ]; then
  845             if [ ".$opt_t" = .yes ]; then
  846                 echo "chown $opt_o $dsttmp" 1>&2
  847             fi
  848             chown $opt_o $dsttmp || shtool_exit $?
  849         fi
  850         if [ ".$opt_g" != . ]; then
  851             if [ ".$opt_t" = .yes ]; then
  852                 echo "chgrp $opt_g $dsttmp" 1>&2
  853             fi
  854             chgrp $opt_g $dsttmp || shtool_exit $?
  855         fi
  856         if [ ".$opt_m" != ".-" ]; then
  857             if [ ".$opt_t" = .yes ]; then
  858                 echo "chmod $opt_m $dsttmp" 1>&2
  859             fi
  860             chmod $opt_m $dsttmp || shtool_exit $?
  861         fi
  862 
  863         #   determine whether to do a quick install
  864         #   (has to be done _after_ the strip was already done)
  865         quick=no
  866         if [ ".$opt_C" = .yes ]; then
  867             if [ -r $dst ]; then
  868                 if cmp -s $src $dst; then
  869                     quick=yes
  870                 fi
  871             fi
  872         fi
  873 
  874         #   finally, install the file to the real destination
  875         if [ $quick = yes ]; then
  876             if [ ".$opt_t" = .yes ]; then
  877                 echo "rm -f $dsttmp" 1>&2
  878             fi
  879             rm -f $dsttmp
  880         else
  881             if [ ".$opt_t" = .yes ]; then
  882                 echo "rm -f $dst && mv $dsttmp $dst" 1>&2
  883             fi
  884             rm -f $dst && mv $dsttmp $dst
  885         fi
  886     done
  887 
  888     shtool_exit 0
  889     ;;
  890 
  891 mkdir )
  892     ##
  893     ##  mkdir -- Make one or more directories
  894     ##  Copyright (c) 1996-2005 Ralf S. Engelschall <rse@engelschall.com>
  895     ##
  896 
  897     errstatus=0
  898     for p in ${1+"$@"}; do
  899         #   if the directory already exists...
  900         if [ -d "$p" ]; then
  901             if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
  902                 echo "$msgprefix:Error: directory already exists: $p" 1>&2
  903                 errstatus=1
  904                 break
  905             else
  906                 continue
  907             fi
  908         fi
  909         #   if the directory has to be created...
  910         if [ ".$opt_p" = .no ]; then
  911             if [ ".$opt_t" = .yes ]; then
  912                 echo "mkdir $p" 1>&2
  913             fi
  914             mkdir $p || errstatus=$?
  915             if [ ".$opt_o" != . ]; then
  916                 if [ ".$opt_t" = .yes ]; then
  917                     echo "chown $opt_o $p" 1>&2
  918                 fi
  919                 chown $opt_o $p || errstatus=$?
  920             fi
  921             if [ ".$opt_g" != . ]; then
  922                 if [ ".$opt_t" = .yes ]; then
  923                     echo "chgrp $opt_g $p" 1>&2
  924                 fi
  925                 chgrp $opt_g $p || errstatus=$?
  926             fi
  927             if [ ".$opt_m" != . ]; then
  928                 if [ ".$opt_t" = .yes ]; then
  929                     echo "chmod $opt_m $p" 1>&2
  930                 fi
  931                 chmod $opt_m $p || errstatus=$?
  932             fi
  933         else
  934             #   the smart situation
  935             set fnord `echo ":$p" |\
  936                        sed -e 's/^:\//%/' \
  937                            -e 's/^://' \
  938                            -e 's/\// /g' \
  939                            -e 's/^%/\//'`
  940             shift
  941             pathcomp=''
  942             for d in ${1+"$@"}; do
  943                 pathcomp="$pathcomp$d"
  944                 case "$pathcomp" in
  945                     -* ) pathcomp="./$pathcomp" ;;
  946                 esac
  947                 if [ ! -d "$pathcomp" ]; then
  948                     if [ ".$opt_t" = .yes ]; then
  949                         echo "mkdir $pathcomp" 1>&2
  950                     fi
  951                     mkdir $pathcomp || errstatus=$?
  952                     if [ ".$opt_o" != . ]; then
  953                         if [ ".$opt_t" = .yes ]; then
  954                             echo "chown $opt_o $pathcomp" 1>&2
  955                         fi
  956                         chown $opt_o $pathcomp || errstatus=$?
  957                     fi
  958                     if [ ".$opt_g" != . ]; then
  959                         if [ ".$opt_t" = .yes ]; then
  960                             echo "chgrp $opt_g $pathcomp" 1>&2
  961                         fi
  962                         chgrp $opt_g $pathcomp || errstatus=$?
  963                     fi
  964                     if [ ".$opt_m" != . ]; then
  965                         if [ ".$opt_t" = .yes ]; then
  966                             echo "chmod $opt_m $pathcomp" 1>&2
  967                         fi
  968                         chmod $opt_m $pathcomp || errstatus=$?
  969                     fi
  970                 fi
  971                 pathcomp="$pathcomp/"
  972             done
  973         fi
  974     done
  975 
  976     shtool_exit $errstatus
  977     ;;
  978 
  979 path )
  980     ##
  981     ##  path -- Deal with program paths
  982     ##  Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
  983     ##
  984 
  985     namelist="$*"
  986 
  987     #   check whether the test command supports the -x option
  988     if [ -x /bin/sh ] 2>/dev/null; then
  989         minusx="-x"
  990     else
  991         minusx="-r"
  992     fi
  993 
  994     #   split path string
  995     paths="`echo $opt_p |\
  996             sed -e 's/^:/.:/' \
  997                 -e 's/::/:.:/g' \
  998                 -e 's/:$/:./' \
  999                 -e 's/:/ /g'`"
 1000 
 1001     #   SPECIAL REQUEST
 1002     #   translate forward to reverse path
 1003     if [ ".$opt_r" = .yes ]; then
 1004         if [ "x$namelist" = "x." ]; then
 1005             rp='.'
 1006         else
 1007             rp=''
 1008             for pe in `IFS="$IFS/"; echo $namelist`; do
 1009                 rp="../$rp"
 1010             done
 1011         fi
 1012         echo $rp | sed -e 's:/$::'
 1013         shtool_exit 0
 1014     fi
 1015 
 1016     #   SPECIAL REQUEST
 1017     #   strip out directory or base name
 1018     if [ ".$opt_d" = .yes ]; then
 1019         echo "$namelist" |\
 1020         sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'
 1021         shtool_exit 0
 1022     fi
 1023     if [ ".$opt_b" = .yes ]; then
 1024         echo "$namelist" |\
 1025         sed -e 's;.*/\([^/]*\)$;\1;'
 1026         shtool_exit 0
 1027     fi
 1028 
 1029     #   MAGIC SITUATION
 1030     #   Perl Interpreter (perl)
 1031     if [ ".$opt_m" = .yes ] && [ ".$namelist" = .perl ]; then
 1032         rm -f $tmpfile >/dev/null 2>&1
 1033         touch $tmpfile
 1034         found=0
 1035         pc=99
 1036         for dir in $paths; do
 1037             dir=`echo $dir | sed -e 's;/*$;;'`
 1038             nc=99
 1039             for name in perl perl5 miniperl; do
 1040                  if [ $minusx "$dir/$name" ] && [ ! -d "$dir/$name" ]; then
 1041                      perl="$dir/$name"
 1042                      pv=`$perl -e 'printf("%.3f", $]);'`
 1043                      echo "$pv:$pc:$nc:$perl" >>$tmpfile
 1044                      found=1
 1045                  fi
 1046                  nc=`expr $nc - 1`
 1047             done
 1048             pc=`expr $pc - 1`
 1049         done
 1050         if [ $found = 1 ]; then
 1051             perl="`cat $tmpfile | sort -r -u | sed -e 'q' | cut -d: -f4`"
 1052             rm -f $tmpfile >/dev/null 2>&1
 1053             echo "$perl"
 1054             shtool_exit 0
 1055         fi
 1056         rm -f $tmpfile >/dev/null 2>&1
 1057         shtool_exit 1
 1058     fi
 1059 
 1060     #   MAGIC SITUATION
 1061     #   C pre-processor (cpp)
 1062     if [ ".$opt_m" = .yes ] && [ ".$namelist" = .cpp ]; then
 1063         echo >$tmpfile.c "#include <assert.h>"
 1064         echo >>$tmpfile.c "Syntax Error"
 1065         #   1. try the standard cc -E approach
 1066         cpp="${CC-cc} -E"
 1067         (eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
 1068         my_error=`grep -v '^ *+' $tmpfile.out`
 1069         if [ ".$my_error" != . ]; then
 1070             #   2. try the cc -E approach and GCC's -traditional-ccp option
 1071             cpp="${CC-cc} -E -traditional-cpp"
 1072             (eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
 1073             my_error=`grep -v '^ *+' $tmpfile.out`
 1074             if [ ".$my_error" != . ]; then
 1075                 #   3. try a standalone cpp command in path and lib dirs
 1076                 for path in $paths /lib /usr/lib /usr/local/lib; do
 1077                     path=`echo $path | sed -e 's;/*$;;'`
 1078                     if [ $minusx "$path/cpp" ] && [ ! -d "$path/cpp" ]; then
 1079                         cpp="$path/cpp"
 1080                         break
 1081                     fi
 1082                 done
 1083                 if [ ".$cpp" != . ]; then
 1084                     (eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
 1085                     my_error=`grep -v '^ *+' $tmpfile.out`
 1086                     if [ ".$my_error" != . ]; then
 1087                         #   ok, we gave up...
 1088                         cpp=''
 1089                     fi
 1090                 fi
 1091             fi
 1092         fi
 1093         rm -f $tmpfile >/dev/null 2>&1
 1094         rm -f $tmpfile.c $tmpfile.out >/dev/null 2>&1
 1095         if [ ".$cpp" != . ]; then
 1096             echo "$cpp"
 1097             shtool_exit 0
 1098         fi
 1099         shtool_exit 1
 1100     fi
 1101 
 1102     #   STANDARD SITUATION
 1103     #   iterate over names
 1104     for name in $namelist; do
 1105         #   iterate over paths
 1106         for path in $paths; do
 1107             path=`echo $path | sed -e 's;/*$;;'`
 1108             if [ $minusx "$path/$name" ] && [ ! -d "$path/$name" ]; then
 1109                 if [ ".$opt_s" != .yes ]; then
 1110                     echo "$path/$name"
 1111                 fi
 1112                 shtool_exit 0
 1113             fi
 1114         done
 1115     done
 1116 
 1117     shtool_exit 1
 1118     ;;
 1119 
 1120 esac
 1121 
 1122 shtool_exit 0
 1123