Blame autoconf/shtool

Packit 679830
#!/bin/sh
Packit 679830
##
Packit 679830
##  GNU shtool -- The GNU Portable Shell Tool
Packit 679830
##  Copyright (c) 1994-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
##
Packit 679830
##  See http://www.gnu.org/software/shtool/ for more information.
Packit 679830
##  See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
Packit 679830
##
Packit 679830
##  Version:  2.0.8 (18-Jul-2008)
Packit 679830
##  Contents: all available modules
Packit 679830
##
Packit 679830
Packit 679830
##
Packit 679830
##  This program is free software; you can redistribute it and/or modify
Packit 679830
##  it under the terms of the GNU General Public License as published by
Packit 679830
##  the Free Software Foundation; either version 2 of the License, or
Packit 679830
##  (at your option) any later version.
Packit 679830
##
Packit 679830
##  This program is distributed in the hope that it will be useful,
Packit 679830
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 679830
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Packit 679830
##  General Public License for more details.
Packit 679830
##
Packit 679830
##  You should have received a copy of the GNU General Public License
Packit 679830
##  along with this program; if not, write to the Free Software
Packit 679830
##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
Packit 679830
##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
Packit 679830
##
Packit 679830
##  NOTICE: Given that you include this file verbatim into your own
Packit 679830
##  source tree, you are justified in saying that it remains separate
Packit 679830
##  from your package, and that this way you are simply just using GNU
Packit 679830
##  shtool. So, in this situation, there is no requirement that your
Packit 679830
##  package itself is licensed under the GNU General Public License in
Packit 679830
##  order to take advantage of GNU shtool.
Packit 679830
##
Packit 679830
Packit 679830
##
Packit 679830
##  Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]
Packit 679830
##
Packit 679830
##  Available commands:
Packit 679830
##    echo       Print string with optional construct expansion
Packit 679830
##    mdate      Pretty-print modification time of a file or dir
Packit 679830
##    table      Pretty-print a field-separated list as a table
Packit 679830
##    prop       Display progress with a running propeller
Packit 679830
##    move       Move files with simultaneous substitution
Packit 679830
##    install    Install a program, script or datafile
Packit 679830
##    mkdir      Make one or more directories
Packit 679830
##    mkln       Make link with calculation of relative paths
Packit 679830
##    mkshadow   Make a shadow tree through symbolic links
Packit 679830
##    fixperm    Fix file permissions inside a source tree
Packit 679830
##    rotate     Logfile rotation
Packit 679830
##    tarball    Roll distribution tarballs
Packit 679830
##    subst      Apply sed(1) substitution operations
Packit 679830
##    platform   Platform Identification Utility
Packit 679830
##    arx        Extended archive command
Packit 679830
##    slo        Separate linker options by library class
Packit 679830
##    scpp       Sharing C Pre-Processor
Packit 679830
##    version    Maintain a version information file
Packit 679830
##    path       Deal with program paths
Packit 679830
##
Packit 679830
Packit 679830
#   maximum Bourne-Shell compatibility
Packit 679830
if [ ".$ZSH_VERSION" != . ] && (emulate sh) >/dev/null 2>&1; then
Packit 679830
    #   reconfigure zsh(1)
Packit 679830
    emulate sh
Packit 679830
    NULLCMD=:
Packit 679830
    alias -g '${1+"$@"}'='"$@"'
Packit 679830
elif [ ".$BASH_VERSION" != . ] && (set -o posix) >/dev/null 2>&1; then
Packit 679830
    #   reconfigure bash(1)
Packit 679830
    set -o posix
Packit 679830
fi
Packit 679830
Packit 679830
#   maximum independence of NLS nuisances
Packit 679830
for var in \
Packit 679830
    LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
Packit 679830
    LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
Packit 679830
    LC_TELEPHONE LC_TIME
Packit 679830
do
Packit 679830
    if (set +x; test -z "`(eval $var=C; export $var) 2>&1`"); then
Packit 679830
        eval $var=C; export $var
Packit 679830
    else
Packit 679830
        unset $var
Packit 679830
    fi
Packit 679830
done
Packit 679830
Packit 679830
#   initial command line handling
Packit 679830
if [ $# -eq 0 ]; then
Packit 679830
    echo "$0:Error: invalid command line" 1>&2
Packit 679830
    echo "$0:Hint:  run \`$0 -h' for usage" 1>&2
Packit 679830
    exit 1
Packit 679830
fi
Packit 679830
if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
Packit 679830
    echo "This is GNU shtool, version 2.0.8 (18-Jul-2008)"
Packit 679830
    echo 'Copyright (c) 1994-2008 Ralf S. Engelschall <rse@engelschall.com>'
Packit 679830
    echo 'Report bugs to <bug-shtool@gnu.org>'
Packit 679830
    echo ''
Packit 679830
    echo 'Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]'
Packit 679830
    echo ''
Packit 679830
    echo 'Available global <options>:'
Packit 679830
    echo '  -v, --version   display shtool version information'
Packit 679830
    echo '  -h, --help      display shtool usage help page (this one)'
Packit 679830
    echo '  -d, --debug     display shell trace information'
Packit 679830
    echo '  -r, --recreate  recreate this shtool script via shtoolize'
Packit 679830
    echo ''
Packit 679830
    echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
Packit 679830
    echo '  echo     [-n|--newline] [-e|--expand] [<string> ...]'
Packit 679830
    echo '  mdate    [-n|--newline] [-z|--zero] [-s|--shorten] [-d|--digits]'
Packit 679830
    echo '           [-f|--field-sep <str>] [-o|--order <spec>] <path>'
Packit 679830
    echo '  table    [-F|--field-sep <sep>] [-w|--width <width>] [-c|--columns'
Packit 679830
    echo '           <cols>] [-s|--strip <strip>] <str><sep><str>...'
Packit 679830
    echo '  prop     [-p|--prefix <str>]'
Packit 679830
    echo '  move     [-v|--verbose] [-t|--trace] [-e|--expand] [-p|--preserve]'
Packit 679830
    echo '           <src-file> <dst-file>'
Packit 679830
    echo '  install  [-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy]'
Packit 679830
    echo '           [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>]'
Packit 679830
    echo '           [-o|--owner <owner>] [-g|--group <group>] [-e|--exec'
Packit 679830
    echo '           <sed-cmd>] <file> [<file> ...] <path>'
Packit 679830
    echo '  mkdir    [-t|--trace] [-f|--force] [-p|--parents] [-m|--mode'
Packit 679830
    echo '           <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir>'
Packit 679830
    echo '           [<dir> ...]'
Packit 679830
    echo '  mkln     [-t|--trace] [-f|--force] [-s|--symbolic] <src-path>'
Packit 679830
    echo '           [<src-path> ...] <dst-path>'
Packit 679830
    echo '  mkshadow [-v|--verbose] [-t|--trace] [-a|--all] <src-dir> <dst-dir>'
Packit 679830
    echo '  fixperm  [-v|--verbose] [-t|--trace] <path> [<path> ...]'
Packit 679830
    echo '  rotate   [-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files'
Packit 679830
    echo '           <count>] [-s|--size <size>] [-c|--copy] [-r|--remove]'
Packit 679830
    echo '           [-a|--archive-dir <dir>] [-z|--compress [<tool>:]<level>]'
Packit 679830
    echo '           [-b|--background] [-d|--delay] [-p|--pad <len>] [-m|--mode'
Packit 679830
    echo '           <mode>] [-o|--owner <owner>] [-g|--group <group>] [-M|--migrate'
Packit 679830
    echo '           <cmd>] [-P|--prolog <cmd>] [-E|--epilog <cmd>] <file> [...]'
Packit 679830
    echo '  tarball  [-t|--trace] [-v|--verbose] [-o|--output <tarball>]'
Packit 679830
    echo '           [-c|--compress <prog>] [-d|--directory <dir>] [-u|--user'
Packit 679830
    echo '           <user>] [-g|--group <group>] [-e|--exclude <pattern>]'
Packit 679830
    echo '           <path> [<path> ...]'
Packit 679830
    echo '  subst    [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning]'
Packit 679830
    echo '           [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup'
Packit 679830
    echo '           <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>]'
Packit 679830
    echo '           [...]'
Packit 679830
    echo '  platform [-F|--format <format>] [-S|--sep <string>] [-C|--conc'
Packit 679830
    echo '           <string>] [-L|--lower] [-U|--upper] [-v|--verbose]'
Packit 679830
    echo '           [-c|--concise] [-n|--no-newline] [-t|--type <type>]'
Packit 679830
    echo '           [-V|--version] [-h|--help]'
Packit 679830
    echo '  arx      [-t|--trace] [-C|--command <cmd>] <op> <archive> [<file>'
Packit 679830
    echo '           ...]'
Packit 679830
    echo '  slo      [-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib>'
Packit 679830
    echo '           ...]'
Packit 679830
    echo '  scpp     [-v|--verbose] [-p|--preserve] [-f|--filter <filter>]'
Packit 679830
    echo '           [-o|--output <ofile>] [-t|--template <tfile>] [-M|--mark'
Packit 679830
    echo '           <mark>] [-D|--define <dname>] [-C|--class <cname>]'
Packit 679830
    echo '           <file> [<file> ...]'
Packit 679830
    echo '  version  [-l|--language <lang>] [-n|--name <name>] [-p|--prefix'
Packit 679830
    echo '           <prefix>] [-s|--set <version>] [-e|--edit] [-i|--increase'
Packit 679830
    echo '           <knob>] [-d|--display <type>] <file>'
Packit 679830
    echo '  path     [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename]'
Packit 679830
    echo '           [-m|--magic] [-p|--path <path>] <str> [<str> ...]'
Packit 679830
    echo ''
Packit 679830
    exit 0
Packit 679830
fi
Packit 679830
if [ ".$1" = ".-v" ] || [ ".$1" = ".--version" ]; then
Packit 679830
    echo "GNU shtool 2.0.8 (18-Jul-2008)"
Packit 679830
    exit 0
Packit 679830
fi
Packit 679830
if [ ".$1" = ".-r" ] || [ ".$1" = ".--recreate" ]; then
Packit 679830
    shtoolize -oshtool all
Packit 679830
    exit 0
Packit 679830
fi
Packit 679830
if [ ".$1" = ".-d" ] || [ ".$1" = ".--debug" ]; then
Packit 679830
    shift
Packit 679830
    set -x
Packit 679830
fi
Packit 679830
name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
Packit 679830
case "$name" in
Packit 679830
    echo|mdate|table|prop|move|install|mkdir|mkln|mkshadow|fixperm|rotate|tarball|subst|platform|arx|slo|scpp|version|path )
Packit 679830
        #   implicit tool command selection
Packit 679830
        tool="$name"
Packit 679830
        ;;
Packit 679830
    * )
Packit 679830
        #   explicit tool command selection
Packit 679830
        tool="$1"
Packit 679830
        shift
Packit 679830
        ;;
Packit 679830
esac
Packit 679830
arg_spec=""
Packit 679830
opt_spec=""
Packit 679830
gen_tmpfile=no
Packit 679830
Packit 679830
##
Packit 679830
##  DISPATCH INTO SCRIPT PROLOG
Packit 679830
##
Packit 679830
Packit 679830
case $tool in
Packit 679830
    echo )
Packit 679830
        str_tool="echo"
Packit 679830
        str_usage="[-n|--newline] [-e|--expand] [<string> ...]"
Packit 679830
        arg_spec="0+"
Packit 679830
        opt_spec="n.e."
Packit 679830
        opt_alias="n:newline,e:expand"
Packit 679830
        opt_n=no
Packit 679830
        opt_e=no
Packit 679830
        ;;
Packit 679830
    mdate )
Packit 679830
        str_tool="mdate"
Packit 679830
        str_usage="[-n|--newline] [-z|--zero] [-s|--shorten] [-d|--digits] [-f|--field-sep <str>] [-o|--order <spec>] <path>"
Packit 679830
        arg_spec="1="
Packit 679830
        opt_spec="n.z.s.d.f:o:"
Packit 679830
        opt_alias="n:newline,z:zero,s:shorten,d:digits,f:field-sep,o:order"
Packit 679830
        opt_n=no
Packit 679830
        opt_z=no
Packit 679830
        opt_s=no
Packit 679830
        opt_d=no
Packit 679830
        opt_f=" "
Packit 679830
        opt_o="dmy"
Packit 679830
        ;;
Packit 679830
    table )
Packit 679830
        str_tool="table"
Packit 679830
        str_usage="[-F|--field-sep <sep>] [-w|--width <width>] [-c|--columns <cols>] [-s|--strip <strip>] <str><sep><str>..."
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="F:w:c:s:"
Packit 679830
        opt_alias="F:field-sep,w:width,c:columns,s:strip"
Packit 679830
        opt_F=":"
Packit 679830
        opt_w=15
Packit 679830
        opt_c=3
Packit 679830
        opt_s=79
Packit 679830
        ;;
Packit 679830
    prop )
Packit 679830
        str_tool="prop"
Packit 679830
        str_usage="[-p|--prefix <str>]"
Packit 679830
        arg_spec="0="
Packit 679830
        opt_spec="p:"
Packit 679830
        opt_alias="p:prefix"
Packit 679830
        opt_p=""
Packit 679830
        ;;
Packit 679830
    move )
Packit 679830
        str_tool="move"
Packit 679830
        str_usage="[-v|--verbose] [-t|--trace] [-e|--expand] [-p|--preserve] <src-file> <dst-file>"
Packit 679830
        arg_spec="2="
Packit 679830
        opt_spec="v.t.e.p."
Packit 679830
        opt_alias="v:verbose,t:trace,e:expand,p:preserve"
Packit 679830
        opt_v=no
Packit 679830
        opt_t=no
Packit 679830
        opt_e=no
Packit 679830
        opt_p=no
Packit 679830
        ;;
Packit 679830
    install )
Packit 679830
        str_tool="install"
Packit 679830
        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>"
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="v.t.d.c.C.s.m:o:g:e+"
Packit 679830
        opt_alias="v:verbose,t:trace,d:mkdir,c:copy,C:compare-copy,s:strip,m:mode,o:owner,g:group,e:exec"
Packit 679830
        opt_v=no
Packit 679830
        opt_t=no
Packit 679830
        opt_d=no
Packit 679830
        opt_c=no
Packit 679830
        opt_C=no
Packit 679830
        opt_s=no
Packit 679830
        opt_m="0755"
Packit 679830
        opt_o=""
Packit 679830
        opt_g=""
Packit 679830
        opt_e=""
Packit 679830
        ;;
Packit 679830
    mkdir )
Packit 679830
        str_tool="mkdir"
Packit 679830
        str_usage="[-t|--trace] [-f|--force] [-p|--parents] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir> [<dir> ...]"
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="t.f.p.m:o:g:"
Packit 679830
        opt_alias="t:trace,f:force,p:parents,m:mode,o:owner,g:group"
Packit 679830
        opt_t=no
Packit 679830
        opt_f=no
Packit 679830
        opt_p=no
Packit 679830
        opt_m=""
Packit 679830
        opt_o=""
Packit 679830
        opt_g=""
Packit 679830
        ;;
Packit 679830
    mkln )
Packit 679830
        str_tool="mkln"
Packit 679830
        str_usage="[-t|--trace] [-f|--force] [-s|--symbolic] <src-path> [<src-path> ...] <dst-path>"
Packit 679830
        arg_spec="2+"
Packit 679830
        opt_spec="t.f.s."
Packit 679830
        opt_alias="t:trace,f:force,s:symbolic"
Packit 679830
        opt_t=no
Packit 679830
        opt_f=no
Packit 679830
        opt_s=no
Packit 679830
        ;;
Packit 679830
    mkshadow )
Packit 679830
        str_tool="mkshadow"
Packit 679830
        str_usage="[-v|--verbose] [-t|--trace] [-a|--all] <src-dir> <dst-dir>"
Packit 679830
        arg_spec="2="
Packit 679830
        opt_spec="v.t.a."
Packit 679830
        opt_alias="v:verbose,t:trace,a:all"
Packit 679830
        opt_v=no
Packit 679830
        opt_t=no
Packit 679830
        opt_a=no
Packit 679830
        ;;
Packit 679830
    fixperm )
Packit 679830
        str_tool="fixperm"
Packit 679830
        str_usage="[-v|--verbose] [-t|--trace] <path> [<path> ...]"
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="v.t."
Packit 679830
        opt_alias="v:verbose,t:trace"
Packit 679830
        opt_v=no
Packit 679830
        opt_t=no
Packit 679830
        ;;
Packit 679830
    rotate )
Packit 679830
        str_tool="rotate"
Packit 679830
        str_usage="[-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files <count>] [-s|--size <size>] [-c|--copy] [-r|--remove] [-a|--archive-dir <dir>] [-z|--compress [<tool>:]<level>] [-b|--background] [-d|--delay] [-p|--pad <len>] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] [-M|--migrate <cmd>] [-P|--prolog <cmd>] [-E|--epilog <cmd>] <file> [...]"
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="v.t.f.n:s:c.r.a:z:b.d.p:o:g:m:M:P:E:"
Packit 679830
        opt_alias="v:verbose,t:trace,f:force,n:num-files,s:size,c:copy,r:remove,a:archive-dir,z:compress,b:background,d:delay,p:pad,o:owner,g:group,m:mode,M:migrate,P:prolog,E:epilog"
Packit 679830
        opt_v=no
Packit 679830
        opt_t=no
Packit 679830
        opt_f=no
Packit 679830
        opt_n=10
Packit 679830
        opt_s=""
Packit 679830
        opt_c=no
Packit 679830
        opt_r=no
Packit 679830
        opt_a=""
Packit 679830
        opt_z=""
Packit 679830
        opt_b=no
Packit 679830
        opt_d=no
Packit 679830
        opt_p=1
Packit 679830
        opt_o=""
Packit 679830
        opt_g=""
Packit 679830
        opt_m=""
Packit 679830
        opt_M=""
Packit 679830
        opt_P=""
Packit 679830
        opt_E=""
Packit 679830
        ;;
Packit 679830
    tarball )
Packit 679830
        str_tool="tarball"
Packit 679830
        str_usage="[-t|--trace] [-v|--verbose] [-o|--output <tarball>] [-c|--compress <prog>] [-d|--directory <dir>] [-u|--user <user>] [-g|--group <group>] [-e|--exclude <pattern>] <path> [<path> ...]"
Packit 679830
        gen_tmpfile=yes
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="t.v.o:c:d:u:g:e:"
Packit 679830
        opt_alias="t:trace,v:verbose,o:output,c:compress,d:directory,u:user,g:group,e:exclude"
Packit 679830
        opt_t=no
Packit 679830
        opt_v=no
Packit 679830
        opt_o=""
Packit 679830
        opt_c=""
Packit 679830
        opt_d=""
Packit 679830
        opt_u=""
Packit 679830
        opt_g=""
Packit 679830
        opt_e="CVS,\\.cvsignore,\\.svn,\\.[oa]\$"
Packit 679830
        ;;
Packit 679830
    subst )
Packit 679830
        str_tool="subst"
Packit 679830
        str_usage="[-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning] [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>] [...]"
Packit 679830
        gen_tmpfile=yes
Packit 679830
        arg_spec="0+"
Packit 679830
        opt_spec="v.t.n.w.q.s.i.b:e+f:"
Packit 679830
        opt_alias="v:verbose,t:trace,n:nop,w:warning,q:quiet,s:stealth,i:interactive,b:backup,e:exec,f:file"
Packit 679830
        opt_v=no
Packit 679830
        opt_t=no
Packit 679830
        opt_n=no
Packit 679830
        opt_w=no
Packit 679830
        opt_q=no
Packit 679830
        opt_s=no
Packit 679830
        opt_i=no
Packit 679830
        opt_b=""
Packit 679830
        opt_e=""
Packit 679830
        opt_f=""
Packit 679830
        ;;
Packit 679830
    platform )
Packit 679830
        str_tool="platform"
Packit 679830
        str_usage="[-F|--format <format>] [-S|--sep <string>] [-C|--conc <string>] [-L|--lower] [-U|--upper] [-v|--verbose] [-c|--concise] [-n|--no-newline] [-t|--type <type>] [-V|--version] [-h|--help]"
Packit 679830
        arg_spec="0="
Packit 679830
        opt_spec="F:S:C:L.U.v.c.n.t:d.V.h."
Packit 679830
        opt_alias="F:format,S:sep,C:conc,L:lower,U:upper,v:verbose,c:consise,t:type,n:no-newline,V:version,h:help"
Packit 679830
        opt_F="%{sp} (%{ap})"
Packit 679830
        opt_S=" "
Packit 679830
        opt_C="/"
Packit 679830
        opt_L=no
Packit 679830
        opt_U=no
Packit 679830
        opt_t=""
Packit 679830
        opt_v=no
Packit 679830
        opt_c=no
Packit 679830
        opt_n=no
Packit 679830
        opt_V=no
Packit 679830
        opt_h=no
Packit 679830
        ;;
Packit 679830
    arx )
Packit 679830
        str_tool="arx"
Packit 679830
        str_usage="[-t|--trace] [-C|--command <cmd>] <op> <archive> [<file> ...]"
Packit 679830
        arg_spec="2+"
Packit 679830
        opt_spec="t.C:"
Packit 679830
        opt_alias="t:trace,C:command"
Packit 679830
        opt_t=no
Packit 679830
        opt_C="ar"
Packit 679830
        ;;
Packit 679830
    slo )
Packit 679830
        str_tool="slo"
Packit 679830
        str_usage="[-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib> ...]"
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="p:"
Packit 679830
        opt_alias="p:prefix"
Packit 679830
        opt_p="SLO_"
Packit 679830
        ;;
Packit 679830
    scpp )
Packit 679830
        str_tool="scpp"
Packit 679830
        str_usage="[-v|--verbose] [-p|--preserve] [-f|--filter <filter>] [-o|--output <ofile>] [-t|--template <tfile>] [-M|--mark <mark>] [-D|--define <dname>] [-C|--class <cname>] <file> [<file> ...]"
Packit 679830
        gen_tmpfile=yes
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="v.p.f+o:t:M:D:C:"
Packit 679830
        opt_alias="v:verbose,p:preserve,f:filter,o:output,t:template,M:mark,D:define,C:class"
Packit 679830
        opt_v=no
Packit 679830
        opt_p=no
Packit 679830
        opt_f=""
Packit 679830
        opt_o="lib.h"
Packit 679830
        opt_t="lib.h.in"
Packit 679830
        opt_M="%%MARK%%"
Packit 679830
        opt_D="cpp"
Packit 679830
        opt_C="intern"
Packit 679830
        ;;
Packit 679830
    version )
Packit 679830
        str_tool="version"
Packit 679830
        str_usage="[-l|--language <lang>] [-n|--name <name>] [-p|--prefix <prefix>] [-s|--set <version>] [-e|--edit] [-i|--increase <knob>] [-d|--display <type>] <file>"
Packit 679830
        arg_spec="1="
Packit 679830
        opt_spec="l:n:p:s:i:e.d:"
Packit 679830
        opt_alias="l:language,n:name,p:prefix,s:set,e:edit,i:increase,d:display"
Packit 679830
        opt_l="txt"
Packit 679830
        opt_n="unknown"
Packit 679830
        opt_p=""
Packit 679830
        opt_s=""
Packit 679830
        opt_e="no"
Packit 679830
        opt_i=""
Packit 679830
        opt_d="short"
Packit 679830
        ;;
Packit 679830
    path )
Packit 679830
        str_tool="path"
Packit 679830
        str_usage="[-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path <path>] <str> [<str> ...]"
Packit 679830
        gen_tmpfile=yes
Packit 679830
        arg_spec="1+"
Packit 679830
        opt_spec="s.r.d.b.m.p:"
Packit 679830
        opt_alias="s:suppress,r:reverse,d:dirname,b:basename,m:magic,p:path"
Packit 679830
        opt_s=no
Packit 679830
        opt_r=no
Packit 679830
        opt_d=no
Packit 679830
        opt_b=no
Packit 679830
        opt_m=no
Packit 679830
        opt_p="$PATH"
Packit 679830
        ;;
Packit 679830
    -* )
Packit 679830
        echo "$0:Error: unknown option \`$tool'" 2>&1
Packit 679830
        echo "$0:Hint:  run \`$0 -h' for usage" 2>&1
Packit 679830
        exit 1
Packit 679830
        ;;
Packit 679830
    * )
Packit 679830
        echo "$0:Error: unknown command \`$tool'" 2>&1
Packit 679830
        echo "$0:Hint:  run \`$0 -h' for usage" 2>&1
Packit 679830
        exit 1
Packit 679830
        ;;
Packit 679830
esac
Packit 679830
Packit 679830
##
Packit 679830
##  COMMON UTILITY CODE
Packit 679830
##
Packit 679830
Packit 679830
#   commonly used ASCII values
Packit 679830
ASC_TAB="	"
Packit 679830
ASC_NL="
Packit 679830
"
Packit 679830
Packit 679830
#   determine name of tool
Packit 679830
if [ ".$tool" != . ]; then
Packit 679830
    #   used inside shtool script
Packit 679830
    toolcmd="$0 $tool"
Packit 679830
    toolcmdhelp="shtool $tool"
Packit 679830
    msgprefix="shtool:$tool"
Packit 679830
else
Packit 679830
    #   used as standalone script
Packit 679830
    toolcmd="$0"
Packit 679830
    toolcmdhelp="sh $0"
Packit 679830
    msgprefix="$str_tool"
Packit 679830
fi
Packit 679830
Packit 679830
#   parse argument specification string
Packit 679830
eval `echo $arg_spec |\
Packit 679830
      sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'`
Packit 679830
Packit 679830
#   parse option specification string
Packit 679830
eval `echo h.$opt_spec |\
Packit 679830
      sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
Packit 679830
Packit 679830
#   parse option alias string
Packit 679830
eval `echo h:help,$opt_alias |\
Packit 679830
      sed -e 's/-/_/g' -e 's/\([a-zA-Z0-9]\):\([^,]*\),*/opt_ALIAS_\2=\1;/g'`
Packit 679830
Packit 679830
#   interate over argument line
Packit 679830
opt_PREV=''
Packit 679830
while [ $# -gt 0 ]; do
Packit 679830
    #   special option stops processing
Packit 679830
    if [ ".$1" = ".--" ]; then
Packit 679830
        shift
Packit 679830
        break
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine option and argument
Packit 679830
    opt_ARG_OK=no
Packit 679830
    if [ ".$opt_PREV" != . ]; then
Packit 679830
        #   merge previous seen option with argument
Packit 679830
        opt_OPT="$opt_PREV"
Packit 679830
        opt_ARG="$1"
Packit 679830
        opt_ARG_OK=yes
Packit 679830
        opt_PREV=''
Packit 679830
    else
Packit 679830
        #   split argument into option and argument
Packit 679830
        case "$1" in
Packit 679830
            --[a-zA-Z0-9]*=*)
Packit 679830
                eval `echo "x$1" |\
Packit 679830
                      sed -e 's/^x--\([a-zA-Z0-9-]*\)=\(.*\)$/opt_OPT="\1";opt_ARG="\2"/'`
Packit 679830
                opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'`
Packit 679830
                eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
Packit 679830
                ;;
Packit 679830
            --[a-zA-Z0-9]*)
Packit 679830
                opt_OPT=`echo "x$1" | cut -c4-`
Packit 679830
                opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'`
Packit 679830
                eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
Packit 679830
                opt_ARG=''
Packit 679830
                ;;
Packit 679830
            -[a-zA-Z0-9]*)
Packit 679830
                eval `echo "x$1" |\
Packit 679830
                      sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
Packit 679830
                          -e 's/";\(.*\)$/"; opt_ARG="\1"/'`
Packit 679830
                ;;
Packit 679830
            -[a-zA-Z0-9])
Packit 679830
                opt_OPT=`echo "x$1" | cut -c3-`
Packit 679830
                opt_ARG=''
Packit 679830
                ;;
Packit 679830
            *)
Packit 679830
                break
Packit 679830
                ;;
Packit 679830
        esac
Packit 679830
    fi
Packit 679830
Packit 679830
    #   eat up option
Packit 679830
    shift
Packit 679830
Packit 679830
    #   determine whether option needs an argument
Packit 679830
    eval "opt_MODE=\$opt_MODE_${opt_OPT}"
Packit 679830
    if [ ".$opt_ARG" = . ] && [ ".$opt_ARG_OK" != .yes ]; then
Packit 679830
        if [ ".$opt_MODE" = ".:" ] || [ ".$opt_MODE" = ".+" ]; then
Packit 679830
            opt_PREV="$opt_OPT"
Packit 679830
            continue
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   process option
Packit 679830
    case $opt_MODE in
Packit 679830
        '.' )
Packit 679830
            #   boolean option
Packit 679830
            eval "opt_${opt_OPT}=yes"
Packit 679830
            ;;
Packit 679830
        ':' )
Packit 679830
            #   option with argument (multiple occurances override)
Packit 679830
            eval "opt_${opt_OPT}=\"\$opt_ARG\""
Packit 679830
            ;;
Packit 679830
        '+' )
Packit 679830
            #   option with argument (multiple occurances append)
Packit 679830
            eval "opt_${opt_OPT}=\"\$opt_${opt_OPT}\${ASC_NL}\$opt_ARG\""
Packit 679830
            ;;
Packit 679830
        * )
Packit 679830
            echo "$msgprefix:Error: unknown option: \`$opt_OPT'" 1>&2
Packit 679830
            echo "$msgprefix:Hint:  run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
Packit 679830
            exit 1
Packit 679830
            ;;
Packit 679830
    esac
Packit 679830
done
Packit 679830
if [ ".$opt_PREV" != . ]; then
Packit 679830
    echo "$msgprefix:Error: missing argument to option \`$opt_PREV'" 1>&2
Packit 679830
    echo "$msgprefix:Hint:  run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
Packit 679830
    exit 1
Packit 679830
fi
Packit 679830
Packit 679830
#   process help option
Packit 679830
if [ ".$opt_h" = .yes ]; then
Packit 679830
    echo "Usage: $toolcmdhelp $str_usage"
Packit 679830
    exit 0
Packit 679830
fi
Packit 679830
Packit 679830
#   complain about incorrect number of arguments
Packit 679830
case $arg_MODE in
Packit 679830
    '=' )
Packit 679830
        if [ $# -ne $arg_NUMS ]; then
Packit 679830
            echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2
Packit 679830
            echo "$msgprefix:Hint:  run \`$toolcmd -h' or \`man shtool' for details" 1>&2
Packit 679830
            exit 1
Packit 679830
        fi
Packit 679830
        ;;
Packit 679830
    '+' )
Packit 679830
        if [ $# -lt $arg_NUMS ]; then
Packit 679830
            echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2
Packit 679830
            echo "$msgprefix:Hint:  run \`$toolcmd -h' or \`man shtool' for details" 1>&2
Packit 679830
            exit 1
Packit 679830
        fi
Packit 679830
        ;;
Packit 679830
esac
Packit 679830
Packit 679830
#   establish a temporary file on request
Packit 679830
if [ ".$gen_tmpfile" = .yes ]; then
Packit 679830
    #   create (explicitly) secure temporary directory
Packit 679830
    if [ ".$TMPDIR" != . ]; then
Packit 679830
        tmpdir="$TMPDIR"
Packit 679830
    elif [ ".$TEMPDIR" != . ]; then
Packit 679830
        tmpdir="$TEMPDIR"
Packit 679830
    else
Packit 679830
        tmpdir="/tmp"
Packit 679830
    fi
Packit 679830
    tmpdir="$tmpdir/.shtool.$$"
Packit 679830
    ( umask 077
Packit 679830
      rm -rf "$tmpdir" >/dev/null 2>&1 || true
Packit 679830
      mkdir  "$tmpdir" >/dev/null 2>&1
Packit 679830
      if [ $? -ne 0 ]; then
Packit 679830
          echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2
Packit 679830
          exit 1
Packit 679830
      fi
Packit 679830
    )
Packit 679830
Packit 679830
    #   create (implicitly) secure temporary file
Packit 679830
    tmpfile="$tmpdir/shtool.tmp"
Packit 679830
    touch "$tmpfile"
Packit 679830
fi
Packit 679830
Packit 679830
#   utility function: map string to lower case
Packit 679830
util_lower () {
Packit 679830
    echo "$1" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
Packit 679830
}
Packit 679830
Packit 679830
#   utility function: map string to upper case
Packit 679830
util_upper () {
Packit 679830
    echo "$1" | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Packit 679830
}
Packit 679830
Packit 679830
#   cleanup procedure
Packit 679830
shtool_exit () {
Packit 679830
    rc="$1"
Packit 679830
    if [ ".$gen_tmpfile" = .yes ]; then
Packit 679830
        rm -rf "$tmpdir" >/dev/null 2>&1 || true
Packit 679830
    fi
Packit 679830
    exit $rc
Packit 679830
}
Packit 679830
Packit 679830
##
Packit 679830
##  DISPATCH INTO SCRIPT BODY
Packit 679830
##
Packit 679830
Packit 679830
case $tool in
Packit 679830
Packit 679830
echo )
Packit 679830
    ##
Packit 679830
    ##  echo -- Print string with optional construct expansion
Packit 679830
    ##  Copyright (c) 1998-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    text="$*"
Packit 679830
Packit 679830
    #   check for broken escape sequence expansion
Packit 679830
    seo=''
Packit 679830
    bytes=`echo '\1' | wc -c | awk '{ printf("%s", $1); }'`
Packit 679830
    if [ ".$bytes" != .3 ]; then
Packit 679830
        bytes=`echo -E '\1' | wc -c | awk '{ printf("%s", $1); }'`
Packit 679830
        if [ ".$bytes" = .3 ]; then
Packit 679830
            seo='-E'
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   check for existing -n option (to suppress newline)
Packit 679830
    minusn=''
Packit 679830
    bytes=`echo -n 123 2>/dev/null | wc -c | awk '{ printf("%s", $1); }'`
Packit 679830
    if [ ".$bytes" = .3 ]; then
Packit 679830
        minusn='-n'
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine terminal bold sequence
Packit 679830
    term_bold=''
Packit 679830
    term_norm=''
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[Bb]'`" != . ]; then
Packit 679830
        case $TERM in
Packit 679830
            #   for the most important terminal types we directly know the sequences
Packit 679830
            xterm|xterm*|vt220|vt220*)
Packit 679830
                term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
Packit 679830
                term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
Packit 679830
                ;;
Packit 679830
            vt100|vt100*|cygwin)
Packit 679830
                term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
Packit 679830
                term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
Packit 679830
                ;;
Packit 679830
            #   for all others, we try to use a possibly existing `tput' or `tcout' utility
Packit 679830
            * )
Packit 679830
                paths=`echo $PATH | sed -e 's/:/ /g'`
Packit 679830
                for tool in tput tcout; do
Packit 679830
                    for dir in $paths; do
Packit 679830
                        if [ -r "$dir/$tool" ]; then
Packit 679830
                            for seq in bold md smso; do # 'smso' is last
Packit 679830
                                bold="`$dir/$tool $seq 2>/dev/null`"
Packit 679830
                                if [ ".$bold" != . ]; then
Packit 679830
                                    term_bold="$bold"
Packit 679830
                                    break
Packit 679830
                                fi
Packit 679830
                            done
Packit 679830
                            if [ ".$term_bold" != . ]; then
Packit 679830
                                for seq in sgr0 me rmso init reset; do # 'reset' is last
Packit 679830
                                    norm="`$dir/$tool $seq 2>/dev/null`"
Packit 679830
                                    if [ ".$norm" != . ]; then
Packit 679830
                                        term_norm="$norm"
Packit 679830
                                        break
Packit 679830
                                    fi
Packit 679830
                                done
Packit 679830
                            fi
Packit 679830
                            break
Packit 679830
                        fi
Packit 679830
                    done
Packit 679830
                    if [ ".$term_bold" != . ] && [ ".$term_norm" != . ]; then
Packit 679830
                        break;
Packit 679830
                    fi
Packit 679830
                done
Packit 679830
                ;;
Packit 679830
        esac
Packit 679830
        if [ ".$term_bold" = . ] || [ ".$term_norm" = . ]; then
Packit 679830
            echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
Packit 679830
            term_bold=''
Packit 679830
            term_norm=''
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine user name
Packit 679830
    username=''
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[uUgG]'`" != . ]; then
Packit 679830
        username="`(id -un) 2>/dev/null`"
Packit 679830
        if [ ".$username" = . ]; then
Packit 679830
            str="`(id) 2>/dev/null`"
Packit 679830
            if [ ".`echo $str | grep '^uid[ 	]*=[ 	]*[0-9]*('`" != . ]; then
Packit 679830
                username=`echo $str | sed -e 's/^uid[ 	]*=[ 	]*[0-9]*(//' -e 's/).*$//'`
Packit 679830
            fi
Packit 679830
            if [ ".$username" = . ]; then
Packit 679830
                username="$LOGNAME"
Packit 679830
                if [ ".$username" = . ]; then
Packit 679830
                    username="$USER"
Packit 679830
                    if [ ".$username" = . ]; then
Packit 679830
                        username="`(whoami) 2>/dev/null |\
Packit 679830
                                   awk '{ printf("%s", $1); }'`"
Packit 679830
                        if [ ".$username" = . ]; then
Packit 679830
                            username="`(who am i) 2>/dev/null |\
Packit 679830
                                       awk '{ printf("%s", $1); }'`"
Packit 679830
                            if [ ".$username" = . ]; then
Packit 679830
                                username='unknown'
Packit 679830
                            fi
Packit 679830
                        fi
Packit 679830
                    fi
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine user id
Packit 679830
    userid=''
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%U'`" != . ]; then
Packit 679830
        userid="`(id -u) 2>/dev/null`"
Packit 679830
        if [ ".$userid" = . ]; then
Packit 679830
            userid="`(id -u ${username}) 2>/dev/null`"
Packit 679830
            if [ ".$userid" = . ]; then
Packit 679830
                str="`(id) 2>/dev/null`"
Packit 679830
                if [ ".`echo $str | grep '^uid[ 	]*=[ 	]*[0-9]*('`" != . ]; then
Packit 679830
                    userid=`echo $str | sed -e 's/^uid[ 	]*=[ 	]*//' -e 's/(.*$//'`
Packit 679830
                fi
Packit 679830
                if [ ".$userid" = . ]; then
Packit 679830
                    userid=`(getent passwd ${username}) 2>/dev/null | \
Packit 679830
                            sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                    if [ ".$userid" = . ]; then
Packit 679830
                        userid=`grep "^${username}:" /etc/passwd 2>/dev/null | \
Packit 679830
                                sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                        if [ ".$userid" = . ]; then
Packit 679830
                            userid=`(ypmatch "${username}" passwd; nismatch "${username}" passwd) 2>/dev/null | \
Packit 679830
                                    sed -e 'q' | sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                            if [ ".$userid" = . ]; then
Packit 679830
                                userid=`(nidump passwd . | grep "^${username}:") 2>/dev/null | \
Packit 679830
                                        sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                                if [ ".$userid" = . ]; then
Packit 679830
                                    userid='?'
Packit 679830
                                fi
Packit 679830
                            fi
Packit 679830
                        fi
Packit 679830
                    fi
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine (primary) group id
Packit 679830
    groupid=''
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[gG]'`" != . ]; then
Packit 679830
        groupid="`(id -g ${username}) 2>/dev/null`"
Packit 679830
        if [ ".$groupid" = . ]; then
Packit 679830
            str="`(id) 2>/dev/null`"
Packit 679830
            if [ ".`echo $str | grep 'gid[ 	]*=[ 	]*[0-9]*('`" != . ]; then
Packit 679830
                groupid=`echo $str | sed -e 's/^.*gid[ 	]*=[ 	]*//' -e 's/(.*$//'`
Packit 679830
            fi
Packit 679830
            if [ ".$groupid" = . ]; then
Packit 679830
                groupid=`(getent passwd ${username}) 2>/dev/null | \
Packit 679830
                         sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                if [ ".$groupid" = . ]; then
Packit 679830
                    groupid=`grep "^${username}:" /etc/passwd 2>/dev/null | \
Packit 679830
                             sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                    if [ ".$groupid" = . ]; then
Packit 679830
                        groupid=`(ypmatch "${username}" passwd; nismatch "${username}" passwd) 2>/dev/null | \
Packit 679830
                                 sed -e 'q' | sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                        if [ ".$groupid" = . ]; then
Packit 679830
                            groupid=`(nidump passwd . | grep "^${username}:") 2>/dev/null | \
Packit 679830
                                     sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
Packit 679830
                            if [ ".$groupid" = . ]; then
Packit 679830
                                groupid='?'
Packit 679830
                            fi
Packit 679830
                        fi
Packit 679830
                    fi
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine (primary) group name
Packit 679830
    groupname=''
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%g'`" != . ]; then
Packit 679830
        groupname="`(id -gn ${username}) 2>/dev/null`"
Packit 679830
        if [ ".$groupname" = . ]; then
Packit 679830
            str="`(id) 2>/dev/null`"
Packit 679830
            if [ ".`echo $str | grep 'gid[ 	]*=[ 	]*[0-9]*('`" != . ]; then
Packit 679830
                groupname=`echo $str | sed -e 's/^.*gid[ 	]*=[ 	]*[0-9]*(//' -e 's/).*$//'`
Packit 679830
            fi
Packit 679830
            if [ ".$groupname" = . ]; then
Packit 679830
                groupname=`(getent group) 2>/dev/null | \
Packit 679830
                           grep "^[^:]*:[^:]*:${groupid}:" | \
Packit 679830
                           sed -e 's/:.*$//'`
Packit 679830
                if [ ".$groupname" = . ]; then
Packit 679830
                    groupname=`grep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \
Packit 679830
                               sed -e 's/:.*$//'`
Packit 679830
                    if [ ".$groupname" = . ]; then
Packit 679830
                        groupname=`(ypcat group; niscat group) 2>/dev/null | \
Packit 679830
                                   sed -e 'q' | grep "^[^:]*:[^:]*:${groupid}:" | \
Packit 679830
                                   sed -e 's/:.*$//'`
Packit 679830
                        if [ ".$groupname" = . ]; then
Packit 679830
                            groupname=`(nidump group .) 2>/dev/null | \
Packit 679830
                                       grep "^[^:]*:[^:]*:${groupid}:" | \
Packit 679830
                                       sed -e 's/:.*$//'`
Packit 679830
                            if [ ".$groupname" = . ]; then
Packit 679830
                                groupname='?'
Packit 679830
                            fi
Packit 679830
                        fi
Packit 679830
                    fi
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine host and domain name
Packit 679830
    hostname=''
Packit 679830
    domainname=''
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%h'`" != . ]; then
Packit 679830
        hostname="`(uname -n) 2>/dev/null |\
Packit 679830
                   awk '{ printf("%s", $1); }'`"
Packit 679830
        if [ ".$hostname" = . ]; then
Packit 679830
            hostname="`(hostname) 2>/dev/null |\
Packit 679830
                       awk '{ printf("%s", $1); }'`"
Packit 679830
            if [ ".$hostname" = . ]; then
Packit 679830
                hostname='unknown'
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
        case $hostname in
Packit 679830
            *.* )
Packit 679830
                domainname=".`echo $hostname | cut -d. -f2-`"
Packit 679830
                hostname="`echo $hostname | cut -d. -f1`"
Packit 679830
                ;;
Packit 679830
        esac
Packit 679830
    fi
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%d'`" != . ]; then
Packit 679830
        if [ ".$domainname" = . ]; then
Packit 679830
            if [ -f /etc/resolv.conf ]; then
Packit 679830
                domainname="`grep '^[ 	]*domain' /etc/resolv.conf | sed -e 'q' |\
Packit 679830
                             sed -e 's/.*domain//' \
Packit 679830
                                 -e 's/^[ 	]*//' -e 's/^ *//' -e 's/^	*//' \
Packit 679830
                                 -e 's/^\.//' -e 's/^/./' |\
Packit 679830
                             awk '{ printf("%s", $1); }'`"
Packit 679830
                if [ ".$domainname" = . ]; then
Packit 679830
                    domainname="`grep '^[ 	]*search' /etc/resolv.conf | sed -e 'q' |\
Packit 679830
                                 sed -e 's/.*search//' \
Packit 679830
                                     -e 's/^[ 	]*//' -e 's/^ *//' -e 's/^	*//' \
Packit 679830
                                     -e 's/ .*//' -e 's/	.*//' \
Packit 679830
                                     -e 's/^\.//' -e 's/^/./' |\
Packit 679830
                                 awk '{ printf("%s", $1); }'`"
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine current time
Packit 679830
    time_day=''
Packit 679830
    time_month=''
Packit 679830
    time_year=''
Packit 679830
    time_monthname=''
Packit 679830
    if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[DMYm]'`" != . ]; then
Packit 679830
        time_day=`date '+%d'`
Packit 679830
        time_month=`date '+%m'`
Packit 679830
        time_year=`date '+%Y' 2>/dev/null`
Packit 679830
        if [ ".$time_year" = . ]; then
Packit 679830
            time_year=`date '+%y'`
Packit 679830
            case $time_year in
Packit 679830
                [5-9][0-9]) time_year="19$time_year" ;;
Packit 679830
                [0-4][0-9]) time_year="20$time_year" ;;
Packit 679830
            esac
Packit 679830
        fi
Packit 679830
        case $time_month in
Packit 679830
            1|01) time_monthname='Jan' ;;
Packit 679830
            2|02) time_monthname='Feb' ;;
Packit 679830
            3|03) time_monthname='Mar' ;;
Packit 679830
            4|04) time_monthname='Apr' ;;
Packit 679830
            5|05) time_monthname='May' ;;
Packit 679830
            6|06) time_monthname='Jun' ;;
Packit 679830
            7|07) time_monthname='Jul' ;;
Packit 679830
            8|08) time_monthname='Aug' ;;
Packit 679830
            9|09) time_monthname='Sep' ;;
Packit 679830
              10) time_monthname='Oct' ;;
Packit 679830
              11) time_monthname='Nov' ;;
Packit 679830
              12) time_monthname='Dec' ;;
Packit 679830
        esac
Packit 679830
    fi
Packit 679830
Packit 679830
    #   expand special ``%x'' constructs
Packit 679830
    if [ ".$opt_e" = .yes ]; then
Packit 679830
        text=`echo $seo "$text" |\
Packit 679830
              sed -e "s/%B/${term_bold}/g" \
Packit 679830
                  -e "s/%b/${term_norm}/g" \
Packit 679830
                  -e "s/%u/${username}/g" \
Packit 679830
                  -e "s/%U/${userid}/g" \
Packit 679830
                  -e "s/%g/${groupname}/g" \
Packit 679830
                  -e "s/%G/${groupid}/g" \
Packit 679830
                  -e "s/%h/${hostname}/g" \
Packit 679830
                  -e "s/%d/${domainname}/g" \
Packit 679830
                  -e "s/%D/${time_day}/g" \
Packit 679830
                  -e "s/%M/${time_month}/g" \
Packit 679830
                  -e "s/%Y/${time_year}/g" \
Packit 679830
                  -e "s/%m/${time_monthname}/g" 2>/dev/null`
Packit 679830
    fi
Packit 679830
Packit 679830
    #   create output
Packit 679830
    if [ .$opt_n = .no ]; then
Packit 679830
        echo $seo "$text"
Packit 679830
    else
Packit 679830
        #   the harder part: echo -n is best, because
Packit 679830
        #   awk may complain about some \xx sequences.
Packit 679830
        if [ ".$minusn" != . ]; then
Packit 679830
            echo $seo $minusn "$text"
Packit 679830
        else
Packit 679830
            echo dummy | awk '{ printf("%s", TEXT); }' TEXT="$text"
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
mdate )
Packit 679830
    ##
Packit 679830
    ##  mdate -- Pretty-print modification time of a file or dir
Packit 679830
    ##  Copyright (c) 1995-1997 Free Software Foundation, Inc.
Packit 679830
    ##  Copyright (c) 1998-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    fod="$1"
Packit 679830
    case "$opt_o" in
Packit 679830
        [dmy][dmy][dmy] )
Packit 679830
            ;;
Packit 679830
        * ) echo "$msgprefix:Error: invalid argument to option \`-o': $opt_o" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
            ;;
Packit 679830
    esac
Packit 679830
    if [ ! -r "$fod" ]; then
Packit 679830
        echo "$msgprefix:Error: file or directory not found: $fod" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   GNU ls changes its time format in response to the TIME_STYLE
Packit 679830
    #   variable. Since we cannot assume "unset" works, revert this
Packit 679830
    #   variable to its documented default.
Packit 679830
    if [ ".$TIME_STYLE" != . ]; then
Packit 679830
        TIME_STYLE=posix-long-iso
Packit 679830
        export TIME_STYLE
Packit 679830
    fi
Packit 679830
Packit 679830
    #   get the extended ls output of the file or directory.
Packit 679830
    if /bin/ls -L /dev/null >/dev/null 2>&1; then
Packit 679830
        set - x`/bin/ls -L -l -d $fod`
Packit 679830
    else
Packit 679830
        set - x`/bin/ls -l -d $fod`
Packit 679830
    fi
Packit 679830
Packit 679830
    #   The month is at least the fourth argument
Packit 679830
    #   (3 shifts here, the next inside the loop).
Packit 679830
    shift; shift; shift
Packit 679830
Packit 679830
    #   Find the month. Next argument is day, followed by the year or time.
Packit 679830
    month=""
Packit 679830
    while [ ".$month" = . ]; do
Packit 679830
        shift
Packit 679830
        case $1 in
Packit 679830
            Jan) month=January;   nummonth=1  ;;
Packit 679830
            Feb) month=February;  nummonth=2  ;;
Packit 679830
            Mar) month=March;     nummonth=3  ;;
Packit 679830
            Apr) month=April;     nummonth=4  ;;
Packit 679830
            May) month=May;       nummonth=5  ;;
Packit 679830
            Jun) month=June;      nummonth=6  ;;
Packit 679830
            Jul) month=July;      nummonth=7  ;;
Packit 679830
            Aug) month=August;    nummonth=8  ;;
Packit 679830
            Sep) month=September; nummonth=9  ;;
Packit 679830
            Oct) month=October;   nummonth=10 ;;
Packit 679830
            Nov) month=November;  nummonth=11 ;;
Packit 679830
            Dec) month=December;  nummonth=12 ;;
Packit 679830
        esac
Packit 679830
    done
Packit 679830
    day="$2"
Packit 679830
    year="$3"
Packit 679830
Packit 679830
    #   We finally have to deal with the problem that the "ls" output
Packit 679830
    #   gives either the time of the day or the year.
Packit 679830
    case $year in
Packit 679830
        *:*)
Packit 679830
            this_year=`date '+%Y' 2>/dev/null`
Packit 679830
            if [ ".$this_year" = . ]; then
Packit 679830
                this_year=`date '+%y'`
Packit 679830
                case $this_year in
Packit 679830
                    [5-9][0-9]) this_year="19$this_year" ;;
Packit 679830
                    [0-4][0-9]) this_year="20$this_year" ;;
Packit 679830
                esac
Packit 679830
            fi
Packit 679830
            #   for the following months of the last year the time notation
Packit 679830
            #   is usually also used for files modified in the last year.
Packit 679830
            this_month=`date '+%m'`
Packit 679830
            if (expr $nummonth \> $this_month) >/dev/null; then
Packit 679830
                this_year=`expr $this_year - 1`
Packit 679830
            fi
Packit 679830
            year="$this_year"
Packit 679830
            ;;
Packit 679830
    esac
Packit 679830
Packit 679830
    #   Optionally fill day and month with leeding zeros
Packit 679830
    if [ ".$opt_z" = .yes ]; then
Packit 679830
        case $day in
Packit 679830
            [0-9][0-9] ) ;;
Packit 679830
                 [0-9] ) day="0$day" ;;
Packit 679830
        esac
Packit 679830
        case $nummonth in
Packit 679830
            [0-9][0-9] ) ;;
Packit 679830
                 [0-9] ) nummonth="0$nummonth" ;;
Packit 679830
        esac
Packit 679830
    fi
Packit 679830
Packit 679830
    #   Optionally use digits for month
Packit 679830
    if [ ".$opt_d" = .yes ]; then
Packit 679830
        month="$nummonth"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   Optionally shorten the month name to three characters
Packit 679830
    if [ ".$opt_s" = .yes ]; then
Packit 679830
        month=`echo $month | cut -c1-3`
Packit 679830
    fi
Packit 679830
Packit 679830
    #   Output the resulting date string
Packit 679830
    echo dummy | awk '{
Packit 679830
        for (i = 0; i < 3; i++) {
Packit 679830
            now = substr(order, 1, 1);
Packit 679830
            order = substr(order, 2);
Packit 679830
            if (now == "d")
Packit 679830
                out = day;
Packit 679830
            else if (now == "m")
Packit 679830
                out = month;
Packit 679830
            else if (now == "y")
Packit 679830
                out = year;
Packit 679830
            if (i < 2)
Packit 679830
                printf("%s%s", out, field);
Packit 679830
            else
Packit 679830
                printf("%s", out);
Packit 679830
        }
Packit 679830
        if (newline != "yes")
Packit 679830
            printf("\n");
Packit 679830
    }' "day=$day" "month=$month" "year=$year" \
Packit 679830
       "field=$opt_f" "order=$opt_o" "newline=$opt_n"
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
table )
Packit 679830
    ##
Packit 679830
    ##  table -- Pretty-print a field-separated list as a table
Packit 679830
    ##  Copyright (c) 1998-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    if [ $opt_c -gt 4 ]; then
Packit 679830
        echo "$msgprefix:Error: Invalid number of colums (1..4 allowed only)" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
    case "x$opt_F" in
Packit 679830
        x? ) ;;
Packit 679830
        *  ) echo "$msgprefix:Error: Invalid separator (one char allowed only)" 1>&2; shtool_exit 1 ;;
Packit 679830
    esac
Packit 679830
Packit 679830
    #   split the list into a table
Packit 679830
    list=`
Packit 679830
        IFS="$opt_F"
Packit 679830
        for entry in $*; do
Packit 679830
            if [ ".$entry" != . ]; then
Packit 679830
                echo "$entry"
Packit 679830
            fi
Packit 679830
        done |\
Packit 679830
        awk "
Packit 679830
            BEGIN { list = \"\"; n = 0; }
Packit 679830
            {
Packit 679830
                list = list \\$1;
Packit 679830
                n = n + 1;
Packit 679830
                if (n < $opt_c) {
Packit 679830
                    list = list \":\";
Packit 679830
                }
Packit 679830
                if (n == $opt_c) {
Packit 679830
                    list = list \"\\n\";
Packit 679830
                    n = 0;
Packit 679830
                }
Packit 679830
            }
Packit 679830
            END { print list; }
Packit 679830
         "
Packit 679830
    `
Packit 679830
Packit 679830
    #   format table cells and make sure table
Packit 679830
    #   doesn't exceed maximum width
Packit 679830
    OIFS="$IFS"
Packit 679830
    IFS='
Packit 679830
'
Packit 679830
    for entry in $list; do
Packit 679830
        case $opt_c in
Packit 679830
            1 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s\\n\", \$1); }'" ;;
Packit 679830
            2 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s %-${opt_w}s\\n\", \$1, \$2); }'" ;;
Packit 679830
            3 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s %-${opt_w}s %-${opt_w}s\\n\", \$1, \$2, \$3); }'" ;;
Packit 679830
            4 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s %-${opt_w}s %-${opt_w}s %-${opt_w}s\\n\", \$1, \$2, \$3, \$4); }'" ;;
Packit 679830
        esac
Packit 679830
    done |\
Packit 679830
    awk "{
Packit 679830
        if (length(\$0) > $opt_s) {
Packit 679830
            printf(\"%s\\n\", substr(\$0, 0, $opt_s-1));
Packit 679830
        } else {
Packit 679830
            print \$0;
Packit 679830
        }
Packit 679830
    }"
Packit 679830
    IFS="$OIFS"
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
prop )
Packit 679830
    ##
Packit 679830
    ##  prop -- Display progress with a running propeller
Packit 679830
    ##  Copyright (c) 1998-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    perl=''
Packit 679830
    for dir in `echo $PATH | sed -e 's/:/ /g'` .; do
Packit 679830
        if [ -f "$dir/perl" ]; then
Packit 679830
            perl="$dir/perl"
Packit 679830
            break
Packit 679830
        fi
Packit 679830
    done
Packit 679830
    if [ ".$perl" != . ]; then
Packit 679830
        #   Perl is preferred because writing to STDERR in
Packit 679830
        #   Perl really writes immediately as one would expect
Packit 679830
        $perl -e '
Packit 679830
            @p = ("|","/","-","\\");
Packit 679830
            $i = 0;
Packit 679830
            while (<STDIN>) {
Packit 679830
                printf(STDERR "\r%s...%s\b", $ARGV[0], $p[$i++]);
Packit 679830
                $i = 0 if ($i > 3);
Packit 679830
            }
Packit 679830
            printf(STDERR "\r%s    \n", $ARGV[0]);
Packit 679830
        ' "$opt_p"
Packit 679830
    else
Packit 679830
        #   But if Perl doesn't exists we use Awk even
Packit 679830
        #   some Awk's buffer even the /dev/stderr writing :-(
Packit 679830
        awk '
Packit 679830
            BEGIN {
Packit 679830
                split("|#/#-#\\", p, "#");
Packit 679830
                i = 1;
Packit 679830
            }
Packit 679830
            {
Packit 679830
                printf("\r%s%c\b", prefix, p[i++]) > "/dev/stderr";
Packit 679830
                if (i > 4) { i = 1; }
Packit 679830
            }
Packit 679830
            END {
Packit 679830
                printf("\r%s    \n", prefix) > "/dev/stderr";
Packit 679830
            }
Packit 679830
        ' "prefix=$opt_p"
Packit 679830
    fi
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
move )
Packit 679830
    ##
Packit 679830
    ##  move -- Move files with simultaneous substitution
Packit 679830
    ##  Copyright (c) 1999-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    src="$1"
Packit 679830
    dst="$2"
Packit 679830
Packit 679830
    #   consistency checks
Packit 679830
    if [ ".$src" = . ] || [ ".$dst" = . ]; then
Packit 679830
        echo "$msgprefix:Error: Invalid arguments" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
    if [ ".$src" = ".$dst" ]; then
Packit 679830
        echo "$msgprefix:Error: Source and destination files are the same" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
    expsrc="$src"
Packit 679830
    if [ ".$opt_e" = .yes ]; then
Packit 679830
        expsrc="`echo $expsrc`"
Packit 679830
    fi
Packit 679830
    if [ ".$opt_e" = .yes ]; then
Packit 679830
        if [ ".`echo "$src" | sed -e 's;^.*\\*.*$;;'`" = ".$src" ]; then
Packit 679830
            echo "$msgprefix:Error: Source doesn't contain wildcard ('*'): $dst" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
        if [ ".`echo "$dst" | sed -e 's;^.*%[1-9].*$;;'`" = ".$dst" ]; then
Packit 679830
            echo "$msgprefix:Error: Destination doesn't contain substitution ('%N'): $dst" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
        if [ ".$expsrc" = ".$src" ]; then
Packit 679830
            echo "$msgprefix:Error: Sources not found or no asterisk : $src" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
    else
Packit 679830
        if [ ! -r "$src" ]; then
Packit 679830
            echo "$msgprefix:Error: Source not found: $src" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine substitution patterns
Packit 679830
    if [ ".$opt_e" = .yes ]; then
Packit 679830
        srcpat=`echo "$src" | sed -e 's/\\./\\\\./g' -e 's/;/\\;/g' -e 's;\\*;\\\\(.*\\\\);g'`
Packit 679830
        dstpat=`echo "$dst" | sed -e 's;%\([1-9]\);\\\\\1;g'`
Packit 679830
    fi
Packit 679830
Packit 679830
    #   iterate over source(s)
Packit 679830
    for onesrc in $expsrc; do
Packit 679830
        if [ .$opt_e = .yes ]; then
Packit 679830
            onedst=`echo $onesrc | sed -e "s;$srcpat;$dstpat;"`
Packit 679830
        else
Packit 679830
            onedst="$dst"
Packit 679830
        fi
Packit 679830
        errorstatus=0
Packit 679830
        if [ ".$opt_v" = .yes ]; then
Packit 679830
            echo "$onesrc -> $onedst"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_p" = .yes ]; then
Packit 679830
            if [ -r $onedst ]; then
Packit 679830
                if cmp -s $onesrc $onedst; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "rm -f $onesrc" 1>&2
Packit 679830
                    fi
Packit 679830
                    rm -f $onesrc || errorstatus=$?
Packit 679830
                else
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "mv -f $onesrc $onedst" 1>&2
Packit 679830
                    fi
Packit 679830
                    mv -f $onesrc $onedst || errorstatus=$?
Packit 679830
                fi
Packit 679830
            else
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "mv -f $onesrc $onedst" 1>&2
Packit 679830
                fi
Packit 679830
                mv -f $onesrc $onedst || errorstatus=$?
Packit 679830
            fi
Packit 679830
        else
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "mv -f $onesrc $onedst" 1>&2
Packit 679830
            fi
Packit 679830
            mv -f $onesrc $onedst || errorstatus=$?
Packit 679830
        fi
Packit 679830
        if [ $errorstatus -ne 0 ]; then
Packit 679830
            break;
Packit 679830
        fi
Packit 679830
    done
Packit 679830
Packit 679830
    shtool_exit $errorstatus
Packit 679830
    ;;
Packit 679830
Packit 679830
install )
Packit 679830
    ##
Packit 679830
    ##  install -- Install a program, script or datafile
Packit 679830
    ##  Copyright (c) 1997-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    #   special case: "shtool install -d <dir> [...]" internally
Packit 679830
    #   maps to "shtool mkdir -f -p -m 755 <dir> [...]"
Packit 679830
    if [ "$opt_d" = yes ]; then
Packit 679830
        cmd="$0 mkdir -f -p -m 755"
Packit 679830
        if [ ".$opt_o" != . ]; then
Packit 679830
            cmd="$cmd -o '$opt_o'"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_g" != . ]; then
Packit 679830
            cmd="$cmd -g '$opt_g'"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_v" = .yes ]; then
Packit 679830
            cmd="$cmd -v"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            cmd="$cmd -t"
Packit 679830
        fi
Packit 679830
        for dir in "$@"; do
Packit 679830
            eval "$cmd $dir" || shtool_exit $?
Packit 679830
        done
Packit 679830
        shtool_exit 0
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine source(s) and destination
Packit 679830
    argc=$#
Packit 679830
    srcs=""
Packit 679830
    while [ $# -gt 1 ]; do
Packit 679830
        srcs="$srcs $1"
Packit 679830
        shift
Packit 679830
    done
Packit 679830
    dstpath="$1"
Packit 679830
Packit 679830
    #   type check for destination
Packit 679830
    dstisdir=0
Packit 679830
    if [ -d $dstpath ]; then
Packit 679830
        dstpath=`echo "$dstpath" | sed -e 's:/$::'`
Packit 679830
        dstisdir=1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   consistency check for destination
Packit 679830
    if [ $argc -gt 2 ] && [ $dstisdir = 0 ]; then
Packit 679830
        echo "$msgprefix:Error: multiple sources require destination to be directory" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   iterate over all source(s)
Packit 679830
    for src in $srcs; do
Packit 679830
        dst=$dstpath
Packit 679830
Packit 679830
        #   if destination is a directory, append the input filename
Packit 679830
        if [ $dstisdir = 1 ]; then
Packit 679830
            dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
Packit 679830
            dst="$dst/$dstfile"
Packit 679830
        fi
Packit 679830
Packit 679830
        #   check for correct arguments
Packit 679830
        if [ ".$src" = ".$dst" ]; then
Packit 679830
            echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2
Packit 679830
            continue
Packit 679830
        fi
Packit 679830
        if [ -d "$src" ]; then
Packit 679830
            echo "$msgprefix:Warning: source \`$src' is a directory - skipped" 1>&2
Packit 679830
            continue
Packit 679830
        fi
Packit 679830
Packit 679830
        #   make a temp file name in the destination directory
Packit 679830
        dsttmp=`echo $dst |\
Packit 679830
                sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \
Packit 679830
                    -e "s;\$;/#INST@$$#;"`
Packit 679830
Packit 679830
        #   verbosity
Packit 679830
        if [ ".$opt_v" = .yes ]; then
Packit 679830
            echo "$src -> $dst" 1>&2
Packit 679830
        fi
Packit 679830
Packit 679830
        #   copy or move the file name to the temp name
Packit 679830
        #   (because we might be not allowed to change the source)
Packit 679830
        if [ ".$opt_C" = .yes ]; then
Packit 679830
            opt_c=yes
Packit 679830
        fi
Packit 679830
        if [ ".$opt_c" = .yes ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "cp $src $dsttmp" 1>&2
Packit 679830
            fi
Packit 679830
            cp "$src" "$dsttmp" || shtool_exit $?
Packit 679830
        else
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "mv $src $dsttmp" 1>&2
Packit 679830
            fi
Packit 679830
            mv "$src" "$dsttmp" || shtool_exit $?
Packit 679830
        fi
Packit 679830
Packit 679830
        #   adjust the target file
Packit 679830
        if [ ".$opt_e" != . ]; then
Packit 679830
            sed='sed'
Packit 679830
            OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS"
Packit 679830
            for e
Packit 679830
            do
Packit 679830
                sed="$sed -e '$e'"
Packit 679830
            done
Packit 679830
            cp "$dsttmp" "$dsttmp.old"
Packit 679830
            chmod u+w $dsttmp
Packit 679830
            eval "$sed <$dsttmp.old >$dsttmp" || shtool_exit $?
Packit 679830
            rm -f $dsttmp.old
Packit 679830
        fi
Packit 679830
        if [ ".$opt_s" = .yes ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "strip $dsttmp" 1>&2
Packit 679830
            fi
Packit 679830
            strip $dsttmp || shtool_exit $?
Packit 679830
        fi
Packit 679830
        if [ ".$opt_o" != . ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "chown $opt_o $dsttmp" 1>&2
Packit 679830
            fi
Packit 679830
            chown $opt_o $dsttmp || shtool_exit $?
Packit 679830
        fi
Packit 679830
        if [ ".$opt_g" != . ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "chgrp $opt_g $dsttmp" 1>&2
Packit 679830
            fi
Packit 679830
            chgrp $opt_g $dsttmp || shtool_exit $?
Packit 679830
        fi
Packit 679830
        if [ ".$opt_m" != ".-" ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "chmod $opt_m $dsttmp" 1>&2
Packit 679830
            fi
Packit 679830
            chmod $opt_m $dsttmp || shtool_exit $?
Packit 679830
        fi
Packit 679830
Packit 679830
        #   determine whether to do a quick install
Packit 679830
        #   (has to be done _after_ the strip was already done)
Packit 679830
        quick=no
Packit 679830
        if [ ".$opt_C" = .yes ]; then
Packit 679830
            if [ -r $dst ]; then
Packit 679830
                if cmp -s "$src" "$dst"; then
Packit 679830
                    quick=yes
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   finally, install the file to the real destination
Packit 679830
        if [ $quick = yes ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "rm -f $dsttmp" 1>&2
Packit 679830
            fi
Packit 679830
            rm -f $dsttmp
Packit 679830
        else
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "rm -f $dst && mv $dsttmp $dst" 1>&2
Packit 679830
            fi
Packit 679830
            rm -f $dst && mv $dsttmp $dst
Packit 679830
        fi
Packit 679830
    done
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
mkdir )
Packit 679830
    ##
Packit 679830
    ##  mkdir -- Make one or more directories
Packit 679830
    ##  Copyright (c) 1996-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    errstatus=0
Packit 679830
    for p in ${1+"$@"}; do
Packit 679830
        #   if the directory already exists...
Packit 679830
        if [ -d "$p" ]; then
Packit 679830
            if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
Packit 679830
                echo "$msgprefix:Error: directory already exists: $p" 1>&2
Packit 679830
                errstatus=1
Packit 679830
                break
Packit 679830
            else
Packit 679830
                continue
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
        #   if the directory has to be created...
Packit 679830
        if [ ".$opt_p" = .no ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "mkdir $p" 1>&2
Packit 679830
            fi
Packit 679830
            mkdir $p || errstatus=$?
Packit 679830
            if [ ".$opt_o" != . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "chown $opt_o $p" 1>&2
Packit 679830
                fi
Packit 679830
                chown $opt_o $p || errstatus=$?
Packit 679830
            fi
Packit 679830
            if [ ".$opt_g" != . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "chgrp $opt_g $p" 1>&2
Packit 679830
                fi
Packit 679830
                chgrp $opt_g $p || errstatus=$?
Packit 679830
            fi
Packit 679830
            if [ ".$opt_m" != . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "chmod $opt_m $p" 1>&2
Packit 679830
                fi
Packit 679830
                chmod $opt_m $p || errstatus=$?
Packit 679830
            fi
Packit 679830
        else
Packit 679830
            #   the smart situation
Packit 679830
            set fnord `echo ":$p" |\
Packit 679830
                       sed -e 's/^:\//%/' \
Packit 679830
                           -e 's/^://' \
Packit 679830
                           -e 's/\// /g' \
Packit 679830
                           -e 's/^%/\//'`
Packit 679830
            shift
Packit 679830
            pathcomp=''
Packit 679830
            for d in ${1+"$@"}; do
Packit 679830
                pathcomp="$pathcomp$d"
Packit 679830
                case "$pathcomp" in
Packit 679830
                    -* ) pathcomp="./$pathcomp" ;;
Packit 679830
                esac
Packit 679830
                if [ ! -d "$pathcomp" ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "mkdir $pathcomp" 1>&2
Packit 679830
                    fi
Packit 679830
                    mkdir $pathcomp || errstatus=$?
Packit 679830
                    if [ ".$opt_o" != . ]; then
Packit 679830
                        if [ ".$opt_t" = .yes ]; then
Packit 679830
                            echo "chown $opt_o $pathcomp" 1>&2
Packit 679830
                        fi
Packit 679830
                        chown $opt_o $pathcomp || errstatus=$?
Packit 679830
                    fi
Packit 679830
                    if [ ".$opt_g" != . ]; then
Packit 679830
                        if [ ".$opt_t" = .yes ]; then
Packit 679830
                            echo "chgrp $opt_g $pathcomp" 1>&2
Packit 679830
                        fi
Packit 679830
                        chgrp $opt_g $pathcomp || errstatus=$?
Packit 679830
                    fi
Packit 679830
                    if [ ".$opt_m" != . ]; then
Packit 679830
                        if [ ".$opt_t" = .yes ]; then
Packit 679830
                            echo "chmod $opt_m $pathcomp" 1>&2
Packit 679830
                        fi
Packit 679830
                        chmod $opt_m $pathcomp || errstatus=$?
Packit 679830
                    fi
Packit 679830
                fi
Packit 679830
                pathcomp="$pathcomp/"
Packit 679830
            done
Packit 679830
        fi
Packit 679830
    done
Packit 679830
Packit 679830
    shtool_exit $errstatus
Packit 679830
    ;;
Packit 679830
Packit 679830
mkln )
Packit 679830
    ##
Packit 679830
    ##  mkln -- Make link with calculation of relative paths
Packit 679830
    ##  Copyright (c) 1998-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    #   determine source(s) and destination
Packit 679830
    args=$#
Packit 679830
    srcs=""
Packit 679830
    while [ $# -gt 1 ]; do
Packit 679830
        srcs="$srcs $1"
Packit 679830
        shift
Packit 679830
    done
Packit 679830
    dst="$1"
Packit 679830
    if [ ! -d $dst ]; then
Packit 679830
        if [ $args -gt 2 ]; then
Packit 679830
            echo "$msgprefix:Error: multiple sources not allowed when target isn't a directory" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine link options
Packit 679830
    lnopt=""
Packit 679830
    if [ ".$opt_f" = .yes ]; then
Packit 679830
        lnopt="$lnopt -f"
Packit 679830
    fi
Packit 679830
    if [ ".$opt_s" = .yes ]; then
Packit 679830
        lnopt="$lnopt -s"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   iterate over sources
Packit 679830
    for src in $srcs; do
Packit 679830
        #   determine if one of the paths is an absolute path,
Packit 679830
        #   because then we _have_ to use an absolute symlink
Packit 679830
        oneisabs=0
Packit 679830
        srcisabs=0
Packit 679830
        dstisabs=0
Packit 679830
        case $src in
Packit 679830
            /* ) oneisabs=1; srcisabs=1 ;;
Packit 679830
        esac
Packit 679830
        case $dst in
Packit 679830
            /* ) oneisabs=1; dstisabs=1 ;;
Packit 679830
        esac
Packit 679830
Packit 679830
        #   split source and destination into dir and base name
Packit 679830
        if [ -d $src ]; then
Packit 679830
            srcdir=`echo $src | sed -e 's;/*$;;'`
Packit 679830
            srcbase=""
Packit 679830
        else
Packit 679830
            srcdir=`echo  $src | sed -e 's;^[^/]*$;;' -e 's;^\(.*/\)[^/]*$;\1;' -e 's;\(.\)/$;\1;'`
Packit 679830
            srcbase=`echo $src | sed -e 's;.*/\([^/]*\)$;\1;'`
Packit 679830
        fi
Packit 679830
        if [ -d $dst ]; then
Packit 679830
            dstdir=`echo $dst | sed -e 's;/*$;;'`
Packit 679830
            dstbase=""
Packit 679830
        else
Packit 679830
            dstdir=`echo  $dst | sed -e 's;^[^/]*$;;' -e 's;^\(.*/\)[^/]*$;\1;' -e 's;\(.\)/$;\1;'`
Packit 679830
            dstbase=`echo $dst | sed -e 's;.*/\([^/]*\)$;\1;'`
Packit 679830
        fi
Packit 679830
Packit 679830
        #   consistency check
Packit 679830
        if [ ".$dstdir" != . ]; then
Packit 679830
            if [ ! -d $dstdir ]; then
Packit 679830
                echo "$msgprefix:Error: destination directory not found: $dstdir" 1>&2
Packit 679830
                shtool_exit 1
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   make sure the source is reachable from the destination
Packit 679830
        if [ $dstisabs = 1 ]; then
Packit 679830
            if [ $srcisabs = 0 ]; then
Packit 679830
                if [ ".$srcdir" = . ]; then
Packit 679830
                    srcdir="`pwd | sed -e 's;/*$;;'`"
Packit 679830
                    srcisabs=1
Packit 679830
                    oneisabs=1
Packit 679830
                elif [ -d $srcdir ]; then
Packit 679830
                    srcdir="`cd $srcdir; pwd | sed -e 's;/*$;;'`"
Packit 679830
                    srcisabs=1
Packit 679830
                    oneisabs=1
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   split away a common prefix
Packit 679830
        prefix=""
Packit 679830
        if [ ".$srcdir" = ".$dstdir" ] && [ ".$srcdir" != . ]; then
Packit 679830
            prefix="$srcdir/"
Packit 679830
            srcdir=""
Packit 679830
            dstdir=""
Packit 679830
        else
Packit 679830
            while [ ".$srcdir" != . ] && [ ".$dstdir" != . ]; do
Packit 679830
                presrc=`echo $srcdir | sed -e 's;^\([^/]*\)/.*;\1;'`
Packit 679830
                predst=`echo $dstdir | sed -e 's;^\([^/]*\)/.*;\1;'`
Packit 679830
                if [ ".$presrc" != ".$predst" ]; then
Packit 679830
                    break
Packit 679830
                fi
Packit 679830
                prefix="$prefix$presrc/"
Packit 679830
                srcdir=`echo $srcdir | sed -e 's;^[^/]*/*;;'`
Packit 679830
                dstdir=`echo $dstdir | sed -e 's;^[^/]*/*;;'`
Packit 679830
            done
Packit 679830
        fi
Packit 679830
Packit 679830
        #   destination prefix is just the common prefix
Packit 679830
        dstpre="$prefix"
Packit 679830
Packit 679830
        #   determine source prefix which is the reverse directory
Packit 679830
        #   step-up corresponding to the destination directory
Packit 679830
        srcpre=""
Packit 679830
        allow_relative_srcpre=no
Packit 679830
        if [ ".$prefix" != . ] && [ ".$prefix" != ./ ]; then
Packit 679830
            allow_relative_srcpre=yes
Packit 679830
        fi
Packit 679830
        if [ $oneisabs = 0 ]; then
Packit 679830
            allow_relative_srcpre=yes
Packit 679830
        fi
Packit 679830
        if [ ".$opt_s" != .yes ]; then
Packit 679830
            allow_relative_srcpre=no
Packit 679830
        fi
Packit 679830
        if [ ".$allow_relative_srcpre" = .yes ]; then
Packit 679830
            pl="$dstdir/"
Packit 679830
            OIFS="$IFS"; IFS='/'
Packit 679830
            for pe in $pl; do
Packit 679830
                [ ".$pe" = .  ] && continue
Packit 679830
                [ ".$pe" = .. ] && continue
Packit 679830
                srcpre="../$srcpre"
Packit 679830
            done
Packit 679830
            IFS="$OIFS"
Packit 679830
        else
Packit 679830
            if [ $srcisabs = 1 ]; then
Packit 679830
                srcpre="$prefix"
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   determine destination symlink name
Packit 679830
        if [ ".$dstbase" = . ]; then
Packit 679830
            if [ ".$srcbase" != . ]; then
Packit 679830
                dstbase="$srcbase"
Packit 679830
            else
Packit 679830
                dstbase=`echo "$prefix$srcdir" | sed -e 's;/*$;;' -e 's;.*/\([^/]*\)$;\1;'`
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   now finalize source and destination directory paths
Packit 679830
        srcdir=`echo $srcdir | sed -e 's;\([^/]\)$;\1/;'`
Packit 679830
        dstdir=`echo $dstdir | sed -e 's;\([^/]\)$;\1/;'`
Packit 679830
Packit 679830
        #   run the final link command
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "ln$lnopt $srcpre$srcdir$srcbase $dstpre$dstdir$dstbase"
Packit 679830
        fi
Packit 679830
        eval ln$lnopt $srcpre$srcdir$srcbase $dstpre$dstdir$dstbase
Packit 679830
    done
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
mkshadow )
Packit 679830
    ##
Packit 679830
    ##  mkshadow -- Make a shadow tree through symbolic links
Packit 679830
    ##  Copyright (c) 1998-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    #   source and destination directory
Packit 679830
    src=`echo "$1" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'`
Packit 679830
    dst=`echo "$2" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'`
Packit 679830
Packit 679830
    #   check whether source exists
Packit 679830
    if [ ! -d $src ]; then
Packit 679830
        echo "$msgprefix:Error: source directory not found: \`$src'" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine if one of the paths is an absolute path,
Packit 679830
    #   because then we have to use an absolute symlink
Packit 679830
    oneisabs=0
Packit 679830
    case $src in
Packit 679830
        /* ) oneisabs=1 ;;
Packit 679830
    esac
Packit 679830
    case $dst in
Packit 679830
        /* ) oneisabs=1 ;;
Packit 679830
    esac
Packit 679830
Packit 679830
    #   determine reverse directory for destination directory
Packit 679830
    dstrevdir=''
Packit 679830
    if [ $oneisabs = 0 ]; then
Packit 679830
        #   derive reverse path from forward path
Packit 679830
        pwd=`pwd`
Packit 679830
        OIFS="$IFS"; IFS='/'
Packit 679830
        for pe in $dst; do
Packit 679830
            if [ "x$pe" = "x.." ]; then
Packit 679830
                OIFS2="$IFS"; IFS="$DIFS"
Packit 679830
                eval `echo "$pwd" |\
Packit 679830
                      sed -e 's:\([^/]*\)$:; dir="\1":' \
Packit 679830
                          -e 's:^\(.*\)/[^/]*;:pwd="\1";:'\
Packit 679830
                          -e 's:^;:pwd="";:'`
Packit 679830
                dstrevdir="$dir/$dstrevdir"
Packit 679830
                IFS="$OIFS2"
Packit 679830
            else
Packit 679830
                dstrevdir="../$dstrevdir"
Packit 679830
            fi
Packit 679830
        done
Packit 679830
        IFS="$OIFS"
Packit 679830
    else
Packit 679830
        src="`cd $src; pwd`";
Packit 679830
    fi
Packit 679830
Packit 679830
    #   create directory tree at destination
Packit 679830
    if [ ! -d $dst ]; then
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "mkdir $dst" 1>&2
Packit 679830
        fi
Packit 679830
        mkdir $dst
Packit 679830
    fi
Packit 679830
    if [ ".$opt_a" = .yes ]; then
Packit 679830
        DIRS=`cd $src; find . -type d -print |\
Packit 679830
              sed -e '/^\.$/d' -e 's:^\./::'`
Packit 679830
    else
Packit 679830
        DIRS=`cd $src; find . -type d -print |\
Packit 679830
              sed -e '/\/CVS/d' -e '/^\.$/d' -e 's:^\./::'`
Packit 679830
    fi
Packit 679830
    for dir in $DIRS; do
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "mkdir $dst/$dir" 1>&2
Packit 679830
        fi
Packit 679830
        mkdir $dst/$dir
Packit 679830
    done
Packit 679830
Packit 679830
    #   fill directory tree with symlinks to files
Packit 679830
    if [ ".$opt_a" = .yes ]; then
Packit 679830
        FILES="`cd $src; find . -depth -print |\
Packit 679830
                sed -e 's/^\.\///'`"
Packit 679830
    else
Packit 679830
        FILES="`cd $src; find . -depth -print |\
Packit 679830
                sed -e '/\.o$/d' -e '/\.a$/d' -e '/\.so$/d' \
Packit 679830
                    -e '/\.cvsignore$/d' -e '/\/CVS/d' \
Packit 679830
                    -e '/\/\.#/d' -e '/\.orig$/d' \
Packit 679830
                    -e 's/^\.\///'`"
Packit 679830
    fi
Packit 679830
    for file in $FILES; do
Packit 679830
         #  don't use `-type f' above for find because of symlinks
Packit 679830
         if [ -d "$src/$file" ]; then
Packit 679830
             continue
Packit 679830
         fi
Packit 679830
         basename=`echo $file | sed -e 's:^.*/::'`
Packit 679830
         dir=`echo $file | sed -e 's:[^/]*$::' -e 's:/$::' -e 's:$:/:' -e 's:^/$::'`
Packit 679830
         from=`echo "$src/$file" | sed -e 's/^\.\///'`
Packit 679830
         to="$dst/$dir$basename"
Packit 679830
         if [ $oneisabs = 0 ]; then
Packit 679830
             if [ ".$dir" != . ]; then
Packit 679830
                 subdir=`echo $dir | sed -e 's:/$::'`
Packit 679830
                 #   derive reverse path from forward path
Packit 679830
                 revdir=''
Packit 679830
                 OIFS="$IFS"; IFS='/'
Packit 679830
                 for pe in $subdir; do
Packit 679830
                     revdir="../$revdir"
Packit 679830
                 done
Packit 679830
                 IFS="$OIFS"
Packit 679830
                 #   finalize from
Packit 679830
                 from="$revdir$from"
Packit 679830
             fi
Packit 679830
             from="$dstrevdir$from"
Packit 679830
         fi
Packit 679830
         if [ ".$opt_v" = .yes ]; then
Packit 679830
             echo "    $to" 1>&2
Packit 679830
         fi
Packit 679830
         if [ ".$opt_t" = .yes ]; then
Packit 679830
             echo "ln -s $from $to" 1>&2
Packit 679830
         fi
Packit 679830
         ln -s $from $to
Packit 679830
    done
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
fixperm )
Packit 679830
    ##
Packit 679830
    ##  fixperm -- Fix file permissions inside a source tree
Packit 679830
    ##  Copyright (c) 1996-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    paths="$*"
Packit 679830
Packit 679830
    #   check whether the test command supports the -x option
Packit 679830
    if [ -x /bin/sh ] 2>/dev/null; then
Packit 679830
        minusx="-x"
Packit 679830
    else
Packit 679830
        minusx="-r"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   iterate over paths
Packit 679830
    for p in $paths; do
Packit 679830
        for file in `find $p -depth -print`; do
Packit 679830
            if [ -f $file ]; then
Packit 679830
                if [ $minusx $file ]; then
Packit 679830
                    if [ ".$opt_v" = .yes ]; then
Packit 679830
                        echo "-rwxr-xr-x $file" 2>&1
Packit 679830
                    fi
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chmod 755 $file" 2>&1
Packit 679830
                    fi
Packit 679830
                    chmod 755 $file
Packit 679830
                else
Packit 679830
                    if [ ".$opt_v" = .yes ]; then
Packit 679830
                        echo "-rw-r--r-- $file" 2>&1
Packit 679830
                    fi
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chmod 644 $file" 2>&1
Packit 679830
                    fi
Packit 679830
                    chmod 644 $file
Packit 679830
                fi
Packit 679830
                continue
Packit 679830
            fi
Packit 679830
            if [ -d $file ]; then
Packit 679830
                if [ ".$opt_v" = .yes ]; then
Packit 679830
                    echo "drwxr-xr-x $file" 2>&1
Packit 679830
                fi
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "chmod 755 $file" 2>&1
Packit 679830
                fi
Packit 679830
                chmod 755 $file
Packit 679830
                continue
Packit 679830
            fi
Packit 679830
            if [ ".$opt_v" = .yes ]; then
Packit 679830
                echo "?????????? $file" 2>&1
Packit 679830
            fi
Packit 679830
        done
Packit 679830
    done
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
rotate )
Packit 679830
    ##
Packit 679830
    ##  rotate -- Logfile rotation
Packit 679830
    ##  Copyright (c) 2001-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    #   make sure we have at least one file to rotate
Packit 679830
    if [ ".$opt_n" = .0 ]; then
Packit 679830
        echo "$msgprefix:Error: invalid argument \`$opt_n' to option -n." 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   canonicalize -s option argument
Packit 679830
    if [ ".$opt_s" != . ]; then
Packit 679830
        if [ ".`expr $opt_s : '[0-9]*$'`" != .0 ]; then
Packit 679830
            :
Packit 679830
        elif [ ".`expr $opt_s : '[0-9]*[Kk]$'`" != .0 ]; then
Packit 679830
            opt_s=`expr $opt_s : '\([0-9]*\)[Kk]$'`
Packit 679830
            opt_s=`expr $opt_s \* 1024`
Packit 679830
        elif [ ".`expr $opt_s : '[0-9]*[Mm]$'`" != .0 ]; then
Packit 679830
            opt_s=`expr $opt_s : '\([0-9]*\)[Mm]$'`
Packit 679830
            opt_s=`expr $opt_s \* 1048576` # 1024*1024
Packit 679830
        elif [ ".`expr $opt_s : '[0-9]*[Gg]$'`" != .0 ]; then
Packit 679830
            opt_s=`expr $opt_s : '\([0-9]*\)[Gg]$'`
Packit 679830
            opt_s=`expr $opt_s \* 1073741824` # 1024*1024*1024
Packit 679830
        else
Packit 679830
            echo "$msgprefix:Error: invalid argument \`$opt_s' to option -s." 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   option -d/-z consistency
Packit 679830
    if [ ".$opt_d" = .yes ] && [ ".$opt_z" = . ]; then
Packit 679830
        echo "$msgprefix:Error: option -d requires option -z." 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   make sure target directory exists
Packit 679830
    if [ ".$opt_a" != . ]; then
Packit 679830
        if [ ! -d $opt_a ]; then
Packit 679830
            if [ ".$opt_f" = .no ]; then
Packit 679830
                echo "$msgprefix:Error: archive directory \`$opt_a' does not exist." 1>&2
Packit 679830
                shtool_exit 1
Packit 679830
            fi
Packit 679830
            mkdir $opt_a || shtool_exit $?
Packit 679830
            chmod 755 $opt_a
Packit 679830
        fi
Packit 679830
        if [ ! -w $opt_a ]; then
Packit 679830
            echo "$msgprefix:Error: archive directory \`$opt_a' not writable." 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine compression approach
Packit 679830
    if [ ".$opt_z" != . ]; then
Packit 679830
        comp_lvl="$opt_z"
Packit 679830
        comp_prg=""
Packit 679830
        case $comp_lvl in
Packit 679830
            *:* ) eval `echo $comp_lvl |\
Packit 679830
                        sed -e 's%^\(.*\):\(.*\)$%comp_prg="\1"; comp_lvl="\2"%'` ;;
Packit 679830
        esac
Packit 679830
Packit 679830
        #   compression level consistency
Packit 679830
        case $comp_lvl in
Packit 679830
            [0-9] )
Packit 679830
                ;;
Packit 679830
            * ) echo "$msgprefix:Error: invalid compression level \`$comp_lvl'" 1>&2
Packit 679830
                shtool_exit 1
Packit 679830
                ;;
Packit 679830
        esac
Packit 679830
Packit 679830
        #   determine a suitable compression tool
Packit 679830
        if [ ".$comp_prg" = . ]; then
Packit 679830
            #   check whether the test command supports the -x option
Packit 679830
            if [ -x /bin/sh ] 2>/dev/null; then
Packit 679830
                minusx="-x"
Packit 679830
            else
Packit 679830
                minusx="-r"
Packit 679830
            fi
Packit 679830
            #   search for tools in $PATH
Packit 679830
            paths="`echo $PATH |\
Packit 679830
                    sed -e 's%/*:%:%g' -e 's%/*$%%' \
Packit 679830
                        -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
Packit 679830
                        -e 's/:/ /g'`"
Packit 679830
            for prg in bzip2 gzip compress; do
Packit 679830
                for path in $paths; do
Packit 679830
                    if [ $minusx "$path/$prg" ] && [ ! -d "$path/$prg" ]; then
Packit 679830
                        comp_prg="$prg"
Packit 679830
                        break
Packit 679830
                    fi
Packit 679830
                done
Packit 679830
                if [ ".$comp_prg" != . ]; then
Packit 679830
                    break
Packit 679830
                fi
Packit 679830
            done
Packit 679830
            if [ ".$comp_prg" = . ]; then
Packit 679830
                echo "$msgprefix:Error: no suitable compression tool found in \$PATH" 1>&2
Packit 679830
                shtool_exit 1
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   determine standard compression extension
Packit 679830
        #   and make sure it is a known tool
Packit 679830
        case $comp_prg in
Packit 679830
            */bzip2    | bzip2    ) comp_ext="bz2" comp_lvl="-$comp_lvl" ;;
Packit 679830
            */gzip     | gzip     ) comp_ext="gz"  comp_lvl="-$comp_lvl" ;;
Packit 679830
            */compress | compress ) comp_ext="Z";  comp_lvl=""           ;;
Packit 679830
            * ) echo "$msgprefix:Error: tool \`$comp_prg' is not a known compression tool" 1>&2
Packit 679830
                shtool_exit 1
Packit 679830
                ;;
Packit 679830
        esac
Packit 679830
        comp_suf=".$comp_ext"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   iterate over all given logfile arguments
Packit 679830
    for file in $*; do
Packit 679830
        #   make sure the logfile exists
Packit 679830
        if [ ! -f $file ]; then
Packit 679830
            if [ ".$opt_f" = .yes ]; then
Packit 679830
                continue
Packit 679830
            fi
Packit 679830
            echo "$msgprefix:Error: logfile \`$file' not found" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
Packit 679830
        #   determine log directory (where original logfile is placed)
Packit 679830
        ldir="."
Packit 679830
        case $file in
Packit 679830
            */* ) eval `echo $file | sed -e 's%^\(.*\)/\([^/]*\)$%ldir="\1"; file="\2";%'` ;;
Packit 679830
        esac
Packit 679830
Packit 679830
        #   determine archive directory (where rotated logfiles are placed)
Packit 679830
        adir="$ldir"
Packit 679830
        if [ ".$opt_a" != . ]; then
Packit 679830
            case "$opt_a" in
Packit 679830
                /* | ./* ) adir="$opt_a" ;;
Packit 679830
                * ) adir="$ldir/$opt_a"  ;;
Packit 679830
            esac
Packit 679830
        fi
Packit 679830
Packit 679830
        #   optionally take logfile size into account
Packit 679830
        if [ ".$opt_s" != . ]; then
Packit 679830
            #   determine size of logfile
Packit 679830
            set -- `env -i /bin/ls -l "$ldir/$file" | sed -e "s;$ldir/$file;;" |\
Packit 679830
                    sed -e 's; -> .*$;;' -e 's;[ 	][ 	]*; ;g'`
Packit 679830
            n=`expr $# - 3`
Packit 679830
            eval "size=\`echo \${$n}\`"
Packit 679830
Packit 679830
            #   skip logfile if size is still too small
Packit 679830
            if [ $size -lt $opt_s ]; then
Packit 679830
                if [ ".$opt_v" = .yes ]; then
Packit 679830
                    echo "$ldir/$file: still too small in size -- skipping"
Packit 679830
                fi
Packit 679830
                continue
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   verbosity
Packit 679830
        if [ ".$opt_v" = .yes ]; then
Packit 679830
            echo "rotating $ldir/$file"
Packit 679830
        fi
Packit 679830
Packit 679830
        #   execute prolog
Packit 679830
        if [ ".$opt_P" != . ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "$opt_P"
Packit 679830
            fi
Packit 679830
            eval $opt_P
Packit 679830
            [ $? -ne 0 ] && shtool_exit $?
Packit 679830
        fi
Packit 679830
Packit 679830
        #   kick away out-rotated logfile
Packit 679830
        n=`expr $opt_n - 1`
Packit 679830
        n=`echo dummy | awk "{ printf(\"%0${opt_p}d\", n); }" n=$n`
Packit 679830
        if [ -f "${adir}/${file}.${n}${comp_suf}" ]; then
Packit 679830
            #   optionally migrate away the out-rotated logfile
Packit 679830
            if [ ".$opt_M" != . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "$opt_M ${adir}/${file}.${n}${comp_suf}"
Packit 679830
                fi
Packit 679830
                eval "$opt_M ${adir}/${file}.${n}${comp_suf}"
Packit 679830
                [ $? -ne 0 ] && shtool_exit $?
Packit 679830
            fi
Packit 679830
            #   finally get rid of the out-rotated logfile
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "rm -f ${adir}/${file}.${n}${comp_suf}"
Packit 679830
            fi
Packit 679830
            rm -f ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
Packit 679830
        fi
Packit 679830
Packit 679830
        #   rotate already archived logfiles
Packit 679830
        while [ $n -gt 0 ]; do
Packit 679830
            m=$n
Packit 679830
            n=`expr $n - 1`
Packit 679830
            n=`echo dummy | awk "{ printf(\"%0${opt_p}d\", n); }" n=$n`
Packit 679830
            if [ $n -eq 0 ] && [ ".$opt_d" = .yes ]; then
Packit 679830
                #   special case: first rotation file under delayed compression situation
Packit 679830
                if [ ! -f "${adir}/${file}.${n}" ]; then
Packit 679830
                    continue
Packit 679830
                fi
Packit 679830
Packit 679830
                #   compress file (delayed)
Packit 679830
                if [ ".$opt_b" = .yes ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "mv ${adir}/${file}.${n} ${adir}/${file}.${m}"
Packit 679830
                    fi
Packit 679830
                    mv ${adir}/${file}.${n} ${adir}/${file}.${m} || shtool_exit $?
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "(${comp_prg} ${comp_lvl} <${adir}/${file}.${m} >${adir}/${file}.${m}${comp_suf}; rm -f ${adir}/${file}.${m}) &"
Packit 679830
                    fi
Packit 679830
                    ( ${comp_prg} ${comp_lvl} \
Packit 679830
                          <${adir}/${file}.${m} \
Packit 679830
                          >${adir}/${file}.${m}${comp_suf} || shtool_exit $?
Packit 679830
                      rm -f ${adir}/${file}.${m} || shtool_exit $?
Packit 679830
                    ) </dev/null >/dev/null 2>&1 &
Packit 679830
                else
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "${comp_prg} ${comp_lvl} <${adir}/${file}.${n} >${adir}/${file}.${m}${comp_suf}"
Packit 679830
                    fi
Packit 679830
                    ${comp_prg} ${comp_lvl} \
Packit 679830
                        <${adir}/${file}.${n} \
Packit 679830
                        >${adir}/${file}.${m}${comp_suf} || shtool_exit $?
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "rm -f ${adir}/${file}.${n}"
Packit 679830
                    fi
Packit 679830
                    rm -f ${adir}/${file}.${n} || shtool_exit $?
Packit 679830
                fi
Packit 679830
Packit 679830
                #   fix file attributes
Packit 679830
                if [ ".$opt_o" != . ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chown $opt_o ${adir}/${file}.${m}${comp_suf}"
Packit 679830
                    fi
Packit 679830
                    chown $opt_o ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
Packit 679830
                fi
Packit 679830
                if [ ".$opt_g" != . ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chgrp $opt_g ${adir}/${file}.${m}${comp_suf}"
Packit 679830
                    fi
Packit 679830
                    chgrp $opt_g ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
Packit 679830
                fi
Packit 679830
                if [ ".$opt_m" != . ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chmod $opt_m ${adir}/${file}.${m}${comp_suf}"
Packit 679830
                    fi
Packit 679830
                    chmod $opt_m ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
Packit 679830
                fi
Packit 679830
            else
Packit 679830
                #   standard case: second and following rotation file
Packit 679830
                if [ ! -f "${adir}/${file}.${n}${comp_suf}" ]; then
Packit 679830
                    continue
Packit 679830
                fi
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "mv ${adir}/${file}.${n}${comp_suf} ${adir}/${file}.${m}${comp_suf}"
Packit 679830
                fi
Packit 679830
                mv ${adir}/${file}.${n}${comp_suf} ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
Packit 679830
            fi
Packit 679830
        done
Packit 679830
Packit 679830
        #   move away current logfile
Packit 679830
        if [ ".$opt_c" = .yes ]; then
Packit 679830
            #   approach: copy[+truncate]
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "cp -p ${ldir}/${file} ${adir}/${file}.${n}"
Packit 679830
            fi
Packit 679830
            cp -p ${ldir}/${file} ${adir}/${file}.${n} || shtool_exit $?
Packit 679830
            if [ ".$opt_r" = .no ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "cp /dev/null ${ldir}/${file}"
Packit 679830
                fi
Packit 679830
                cp /dev/null ${ldir}/${file} || shtool_exit $?
Packit 679830
            fi
Packit 679830
        else
Packit 679830
            #   approach: move[+touch]
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "mv ${ldir}/${file} ${adir}/${file}.${n}"
Packit 679830
            fi
Packit 679830
            mv ${ldir}/${file} ${adir}/${file}.${n} || shtool_exit $?
Packit 679830
            if [ ".$opt_r" = .no ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "touch ${ldir}/${file}"
Packit 679830
                fi
Packit 679830
                touch ${ldir}/${file} || shtool_exit $?
Packit 679830
                #   fix file attributes
Packit 679830
                if [ ".$opt_o" != . ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chown $opt_o ${ldir}/${file}"
Packit 679830
                    fi
Packit 679830
                    chown $opt_o ${ldir}/${file} || shtool_exit $?
Packit 679830
                fi
Packit 679830
                if [ ".$opt_g" != . ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chgrp $opt_g ${ldir}/${file}"
Packit 679830
                    fi
Packit 679830
                    chgrp $opt_g ${ldir}/${file} || shtool_exit $?
Packit 679830
                fi
Packit 679830
                if [ ".$opt_m" != . ]; then
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "chmod $opt_m ${ldir}/${file}"
Packit 679830
                    fi
Packit 679830
                    chmod $opt_m ${ldir}/${file} || shtool_exit $?
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   regular compression step
Packit 679830
        if [ ".$opt_z" != . ] && [ ".$opt_d" = .no ]; then
Packit 679830
            #   compress file
Packit 679830
            if [ ".$opt_b" = .yes ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "(${comp_prg} ${comp_lvl} <${adir}/${file}.${n} >${adir}/${file}.${n}${comp_suf}; rm -f ${adir}/${file}.${n}) &"
Packit 679830
                fi
Packit 679830
                ( ${comp_prg} ${comp_lvl} \
Packit 679830
                      <${adir}/${file}.${n} \
Packit 679830
                      >${adir}/${file}.${n}${comp_suf} || shtool_exit $?
Packit 679830
                  rm -f ${adir}/${file}.${n} || shtool_exit $?
Packit 679830
                ) </dev/null >/dev/null 2>&1 &
Packit 679830
            else
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "${comp_prg} ${comp_lvl} <${adir}/${file}.${n} >${adir}/${file}.${n}${comp_suf}"
Packit 679830
                fi
Packit 679830
                ${comp_prg} ${comp_lvl} \
Packit 679830
                    <${adir}/${file}.${n} \
Packit 679830
                    >${adir}/${file}.${n}${comp_suf} || shtool_exit $?
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "rm -f ${opt_a}${file}.${n}"
Packit 679830
                fi
Packit 679830
                rm -f ${adir}/${file}.${n} || shtool_exit $?
Packit 679830
            fi
Packit 679830
Packit 679830
            #   fix file attributes
Packit 679830
            if [ ".$opt_o" != . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "chown $opt_o ${adir}/${file}.${n}${comp_suf}"
Packit 679830
                fi
Packit 679830
                chown $opt_o ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
Packit 679830
            fi
Packit 679830
            if [ ".$opt_g" != . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "chgrp $opt_g ${adir}/${file}.${n}${comp_suf}"
Packit 679830
                fi
Packit 679830
                chgrp $opt_g ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
Packit 679830
            fi
Packit 679830
            if [ ".$opt_m" != . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "chmod $opt_m ${adir}/${file}.${n}${comp_suf}"
Packit 679830
                fi
Packit 679830
                chmod $opt_m ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
Packit 679830
        #   execute epilog
Packit 679830
        if [ ".$opt_E" != . ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "$opt_E"
Packit 679830
            fi
Packit 679830
            eval $opt_E
Packit 679830
            [ $? -ne 0 ] && shtool_exit $?
Packit 679830
        fi
Packit 679830
    done
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
tarball )
Packit 679830
    ##
Packit 679830
    ##  tarball -- Roll distribution tarballs
Packit 679830
    ##  Copyright (c) 1999-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    srcs="$*"
Packit 679830
Packit 679830
    #   check whether the test command supports the -x option
Packit 679830
    if [ -x /bin/sh ] 2>/dev/null; then
Packit 679830
        minusx="-x"
Packit 679830
    else
Packit 679830
        minusx="-r"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   find the tools
Packit 679830
    paths="`echo $PATH |\
Packit 679830
            sed -e 's%/*:%:%g' -e 's%/*$%%' \
Packit 679830
                -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
Packit 679830
                -e 's/:/ /g'`"
Packit 679830
    for spec in find:gfind,find tar:gtar,tar tardy:tardy,tarcust; do
Packit 679830
        prg=`echo $spec | sed -e 's/:.*$//'`
Packit 679830
        tools=`echo $spec | sed -e 's/^.*://'`
Packit 679830
        eval "prg_${prg}=''"
Packit 679830
        #   iterate over tools
Packit 679830
        for tool in `echo $tools | sed -e 's/,/ /g'`; do
Packit 679830
            #   iterate over paths
Packit 679830
            for path in $paths; do
Packit 679830
                if [ $minusx "$path/$tool" ] && [ ! -d "$path/$tool" ]; then
Packit 679830
                    eval "prg_${prg}=\"$path/$tool\""
Packit 679830
                    break
Packit 679830
                fi
Packit 679830
            done
Packit 679830
            eval "val=\$prg_${prg}"
Packit 679830
            if [ ".$val" != . ]; then
Packit 679830
                break
Packit 679830
            fi
Packit 679830
        done
Packit 679830
    done
Packit 679830
Packit 679830
    #   expand source paths
Packit 679830
    exclude=''
Packit 679830
    for pat in `echo $opt_e | sed 's/,/ /g'`; do
Packit 679830
        exclude="$exclude | grep -v '$pat'"
Packit 679830
    done
Packit 679830
    if [ ".$opt_t" = .yes ]; then
Packit 679830
        echo "cp /dev/null $tmpfile.lst" 1>&2
Packit 679830
    fi
Packit 679830
    cp /dev/null $tmpfile.lst
Packit 679830
    for src in $srcs; do
Packit 679830
        if [ -d $src ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "(cd $src && $prg_find . -type f -depth -print) | sed -e 's:^\\.\$::' -e 's:^\\./::' | cat $exclude >>$tmpfile.lst" 1>&2
Packit 679830
            fi
Packit 679830
            (cd $src && $prg_find . -type f -depth -print) |\
Packit 679830
            sed -e 's:^\.$::' -e 's:^\./::' | eval cat $exclude >>$tmpfile.lst
Packit 679830
        else
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "echo $src >>$tmpfile.lst" 1>&2
Packit 679830
            fi
Packit 679830
            echo $src >>$tmpfile.lst
Packit 679830
        fi
Packit 679830
    done
Packit 679830
    sort <$tmpfile.lst >$tmpfile.lst.n
Packit 679830
    mv $tmpfile.lst.n $tmpfile.lst
Packit 679830
    if [ ".$opt_v" = .yes ]; then
Packit 679830
        cat $tmpfile.lst | sed -e 's/^/  /' 1>&2
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine tarball file and directory name
Packit 679830
    if [ ".$opt_o" != . ]; then
Packit 679830
        tarfile="$opt_o"
Packit 679830
        if [ ".$opt_d" != . ]; then
Packit 679830
            tarname="$opt_d"
Packit 679830
        else
Packit 679830
            tarname=`echo $tarfile | sed -e 's/\.tar.*$//' -e 's;.*/\([^/]*\)$;\1;'`
Packit 679830
        fi
Packit 679830
    else
Packit 679830
        if [ ".$opt_d" != . ]; then
Packit 679830
            tarname="$opt_d"
Packit 679830
        elif [ -d "$from" ]; then
Packit 679830
            tarname=`echo $from | sed -e 's;.*/\([^/]*\)$;\1;'`
Packit 679830
        else
Packit 679830
            tarname="out"
Packit 679830
        fi
Packit 679830
        tarfile="$tarname.tar"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   roll the tarball
Packit 679830
    compress=''
Packit 679830
    if [ ".$opt_c" != . ]; then
Packit 679830
        compress="| $opt_c"
Packit 679830
    fi
Packit 679830
    if [ ".$prg_tardy" != . ]; then
Packit 679830
        #   the elegant hackers way
Packit 679830
        tardy_opt="--prefix=$tarname"
Packit 679830
        tardy_opt="$tardy_opt --user_number=0 --group_number=0" # security!
Packit 679830
        if [ ".$opt_u" != . ]; then
Packit 679830
            tardy_opt="$tardy_opt --user_name=$opt_u"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_g" != . ]; then
Packit 679830
            tardy_opt="$tardy_opt --group_name=$opt_g"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "cat $tmpfile.lst | xargs $prg_tar cf - | $prg_tardy $tardy_opt | cat $compress >$tmpfile.out" 1>&2
Packit 679830
        fi
Packit 679830
        cat $tmpfile.lst |\
Packit 679830
        xargs $prg_tar cf - |\
Packit 679830
        $prg_tardy $tardy_opt |\
Packit 679830
        eval cat $compress >$tmpfile.out
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "cp $tmpfile.out $tarfile" 1>&2
Packit 679830
        fi
Packit 679830
        cp $tmpfile.out $tarfile
Packit 679830
    else
Packit 679830
        #  the portable standard way
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "mkdir $tmpdir/$tarname" 1>&2
Packit 679830
        fi
Packit 679830
        mkdir $tmpdir/$tarname || shtool_exit 1
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "cat $tmpfile.lst | xargs $prg_tar cf - | (cd $tmpdir/$tarname && $prg_tar xf -)" 1>&2
Packit 679830
        fi
Packit 679830
        cat $tmpfile.lst |\
Packit 679830
        xargs $prg_tar cf - |\
Packit 679830
        (cd $tmpdir/$tarname && $prg_tar xf -)
Packit 679830
        if [ ".$opt_u" != . ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1" 2>&1
Packit 679830
            fi
Packit 679830
            chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1 ||\
Packit 679830
            echo "$msgprefix:Warning: cannot set user name \`$opt_u' (would require root privileges)"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_g" != . ]; then
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1" 2>&1
Packit 679830
            fi
Packit 679830
            chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1 ||\
Packit 679830
            echo "$msgprefix:Warning: cannot set group name \`$opt_g' (would require root privileges)"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "(cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) | cat $compress >$tmpfile.out" 1>&2
Packit 679830
        fi
Packit 679830
        (cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) |\
Packit 679830
        eval cat $compress >$tmpfile.out
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "cp $tmpfile.out $tarfile" 1>&2
Packit 679830
        fi
Packit 679830
        cp $tmpfile.out $tarfile
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "rm -rf $tmpdir/$tarname" 1>&2
Packit 679830
        fi
Packit 679830
        rm -rf $tmpdir/$tarname
Packit 679830
    fi
Packit 679830
Packit 679830
    #   cleanup
Packit 679830
    if [ ".$opt_t" = .yes ]; then
Packit 679830
        echo "rm -f $tmpfile.lst $tmpfile.out" 1>&2
Packit 679830
    fi
Packit 679830
    rm -f $tmpfile.lst $tmpfile.out
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
subst )
Packit 679830
    ##
Packit 679830
    ##  subst -- Apply sed(1) substitution operations
Packit 679830
    ##  Copyright (c) 2001-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    #   remember optional list of file(s)
Packit 679830
    files="$*"
Packit 679830
    files_num="$#"
Packit 679830
Packit 679830
    #   parameter consistency check
Packit 679830
    if [ $# -eq 0 ] && [ ".$opt_b" != . ]; then
Packit 679830
        echo "$msgprefix:Error: option -b cannot be applied to stdin" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
    if [ $# -eq 0 ] && [ ".$opt_s" = .yes ]; then
Packit 679830
        echo "$msgprefix:Error: option -s cannot be applied to stdin" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   build underlying sed(1) command
Packit 679830
    sedcmd='sed'
Packit 679830
    if [ ".$opt_e" != . ]; then
Packit 679830
        OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS"
Packit 679830
        for e
Packit 679830
        do
Packit 679830
            sedcmd="$sedcmd -e '$e'"
Packit 679830
        done
Packit 679830
    elif [ ".$opt_f" != . ]; then
Packit 679830
        if [ ! -f $opt_f ]; then
Packit 679830
            echo "$msgprefix:Error: command file \`$opt_f' not found or not a regular file" 1>&2
Packit 679830
            shtool_exit 1
Packit 679830
        fi
Packit 679830
        sedcmd="$sedcmd -f '$opt_f'"
Packit 679830
    else
Packit 679830
        echo "$msgprefix:Error: either -e option(s) or -f option required" 1>&2
Packit 679830
        shtool_exit 1
Packit 679830
    fi
Packit 679830
Packit 679830
    #   determine extension for original file
Packit 679830
    orig=".orig"
Packit 679830
    if [ ".$opt_b" != . ]; then
Packit 679830
        orig="$opt_b"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   apply sed(1) operation(s)
Packit 679830
    if [ ".$files" != . ]; then
Packit 679830
        #   apply operation(s) to files
Packit 679830
        substdone=no
Packit 679830
        for file in $files; do
Packit 679830
            test ".$file" = . && continue
Packit 679830
            if [ ! -f $file ]; then
Packit 679830
                echo "$msgprefix:Warning: file \`$file' not found or not a regular file" 1>&2
Packit 679830
                continue
Packit 679830
            fi
Packit 679830
Packit 679830
            #   handle interactive mode
Packit 679830
            if [ ".$opt_i" = .yes ]; then
Packit 679830
                eval "$sedcmd <$file >$file.new"
Packit 679830
                skip=no
Packit 679830
                if cmp $file $file.new >/dev/null 2>&1; then
Packit 679830
                    rm -f $file.new
Packit 679830
                    skip=yes
Packit 679830
                else
Packit 679830
                    (diff -U1 $file $file.new >$tmpfile) 2>/dev/null
Packit 679830
                    if [ ".`cat $tmpfile`" = . ]; then
Packit 679830
                        (diff -C1 $file $file.new >$tmpfile) 2>/dev/null
Packit 679830
                        if [ ".`cat $tmpfile`" = . ]; then
Packit 679830
                            echo "$msgprefix:Warning: unable to show difference for file \`$file'" 1>&2
Packit 679830
                            cp /dev/null $tmpfile
Packit 679830
                        fi
Packit 679830
                    fi
Packit 679830
                    rm -f $file.new
Packit 679830
                    cat $tmpfile
Packit 679830
                    echo dummy | awk '{ printf("%s", TEXT); }' TEXT=">>> Apply [Y/n]: "
Packit 679830
                    read input
Packit 679830
                    if [ ".$input" != .Y ] &&\
Packit 679830
                       [ ".$input" != .y ] &&\
Packit 679830
                       [ ".$input" != . ]; then
Packit 679830
                       skip=yes
Packit 679830
                    fi
Packit 679830
                fi
Packit 679830
                if [ ".$skip" = .yes ]; then
Packit 679830
                    if [ ".$opt_v" = .yes ]; then
Packit 679830
                        echo "file \`$file' -- skipped" 1>&2
Packit 679830
                    fi
Packit 679830
                    continue
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
Packit 679830
            #   apply sed(1) operation(s)
Packit 679830
            if [ ".$opt_v" = .yes ]; then
Packit 679830
                echo "patching \`$file'" 1>&2
Packit 679830
            fi
Packit 679830
            if [ ".$opt_t" = .yes ]; then
Packit 679830
                echo "\$ cp -p $file $file$orig"
Packit 679830
                echo "\$ chmod u+w $file"
Packit 679830
                echo "\$ $sedcmd <$file$orig >$file"
Packit 679830
            fi
Packit 679830
            if [ ".$opt_n" = .no ]; then
Packit 679830
                cp -p $file $file$orig
Packit 679830
                chmod u+w $file >/dev/null 2>&1 || true
Packit 679830
                eval "$sedcmd <$file$orig >$file"
Packit 679830
            fi
Packit 679830
Packit 679830
            #   optionally fix timestamp
Packit 679830
            if [ ".$opt_s" = .yes ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "\$ touch -r $file$orig $file"
Packit 679830
                fi
Packit 679830
                if [ ".$opt_n" = .no ]; then
Packit 679830
                    touch -r $file$orig $file
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
Packit 679830
            #   optionally check whether any content change actually occurred
Packit 679830
            if [ ".$opt_q" = .no ]; then
Packit 679830
                if cmp $file$orig $file >/dev/null 2>&1; then
Packit 679830
                    if [ ".$opt_w" = .yes ]; then
Packit 679830
                        echo "$msgprefix:Warning: substitution resulted in no content change on file \"$file\"" 1>&2
Packit 679830
                    fi
Packit 679830
                else
Packit 679830
                    substdone=yes
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
Packit 679830
            #   optionally remove preserved original file
Packit 679830
            if [ ".$opt_b" = . ]; then
Packit 679830
                if [ ".$opt_t" = .yes ]; then
Packit 679830
                    echo "\$ rm -f $file$orig"
Packit 679830
                fi
Packit 679830
                if [ ".$opt_n" = .no ]; then
Packit 679830
                    rm -f $file$orig
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        done
Packit 679830
        if [ ".$opt_q" = .no ] && [ ".$opt_w" = .no ]; then
Packit 679830
            if [ ".$substdone" = .no ]; then
Packit 679830
                if [ ".$files_num" = .1 ]; then
Packit 679830
                    echo "$msgprefix:Warning: substitution resulted in no content change on file \"$file\"" 1>&2
Packit 679830
                else
Packit 679830
                    echo "$msgprefix:Warning: substitution resulted in no content change on any file" 1>&2
Packit 679830
                fi
Packit 679830
            fi
Packit 679830
        fi
Packit 679830
    else
Packit 679830
        #   apply operation(s) to stdin/stdout
Packit 679830
        if [ ".$opt_v" = .yes ]; then
Packit 679830
            echo "patching <stdin>" 1>&2
Packit 679830
        fi
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "\$ $sedcmd"
Packit 679830
        fi
Packit 679830
        if [ ".$opt_n" = .no ]; then
Packit 679830
            eval "$sedcmd"
Packit 679830
        fi
Packit 679830
    fi
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
platform )
Packit 679830
    ##
Packit 679830
    ##  platform -- Platform Identification Utility
Packit 679830
    ##  Copyright (c) 2003-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    #   option post-processing
Packit 679830
    if [ ".$opt_t" != . ]; then
Packit 679830
        case "$opt_t" in
Packit 679830
            binary )
Packit 679830
                #   binary package id (OpenPKG RPM)
Packit 679830
                opt_F="%<ap>-%<sp>"
Packit 679830
                opt_L=yes
Packit 679830
                opt_S=""
Packit 679830
                opt_C="+"
Packit 679830
                ;;
Packit 679830
            build )
Packit 679830
                #   build time checking (OpenPKG RPM)
Packit 679830
                opt_F="%<at>-%<st>"
Packit 679830
                opt_L=yes
Packit 679830
                opt_S=""
Packit 679830
                opt_C="+"
Packit 679830
                ;;
Packit 679830
            gnu )
Packit 679830
                #   GNU config.guess style <arch>-<vendor>-<os><osversion>
Packit 679830
                opt_F="%<at>-unknown-%<st>"
Packit 679830
                opt_L=yes
Packit 679830
                opt_S=""
Packit 679830
                opt_C="+"
Packit 679830
                ;;
Packit 679830
            web )
Packit 679830
                #   non-whitespace HTTP Server-header id
Packit 679830
                opt_F="%<sp>-%<ap>"
Packit 679830
                opt_S="/"
Packit 679830
                opt_C="+"
Packit 679830
                ;;
Packit 679830
            summary)
Packit 679830
                #   human readable verbose summary information
Packit 679830
                opt_F="Class:      %[sc] (%[ac])\\nProduct:    %[sp] (%[ap])\\nTechnology: %[st] (%[at])"
Packit 679830
                opt_S=" "
Packit 679830
                opt_C="/"
Packit 679830
                ;;
Packit 679830
            all-in-one )
Packit 679830
                #   full-table all-in-one information
Packit 679830
                opt_F=""
Packit 679830
                opt_F="${opt_F}concise architecture class:      %<ac>\\n"
Packit 679830
                opt_F="${opt_F}regular architecture class:      %{ac}\\n"
Packit 679830
                opt_F="${opt_F}verbose architecture class:      %[ac]\\n"
Packit 679830
                opt_F="${opt_F}concise architecture product:    %<ap>\\n"
Packit 679830
                opt_F="${opt_F}regular architecture product:    %{ap}\\n"
Packit 679830
                opt_F="${opt_F}verbose architecture product:    %[ap]\\n"
Packit 679830
                opt_F="${opt_F}concise architecture technology: %<at>\\n"
Packit 679830
                opt_F="${opt_F}regular architecture technology: %{at}\\n"
Packit 679830
                opt_F="${opt_F}verbose architecture technology: %[at]\\n"
Packit 679830
                opt_F="${opt_F}concise system class:            %<sc>\\n"
Packit 679830
                opt_F="${opt_F}regular system class:            %{sc}\\n"
Packit 679830
                opt_F="${opt_F}verbose system class:            %[sc]\\n"
Packit 679830
                opt_F="${opt_F}concise system product:          %<sp>\\n"
Packit 679830
                opt_F="${opt_F}regular system product:          %{sp}\\n"
Packit 679830
                opt_F="${opt_F}verbose system product:          %[sp]\\n"
Packit 679830
                opt_F="${opt_F}concise system technology:       %<st>\\n"
Packit 679830
                opt_F="${opt_F}regular system technology:       %{st}\\n"
Packit 679830
                opt_F="${opt_F}verbose system technology:       %[st]"
Packit 679830
                ;;
Packit 679830
            * )
Packit 679830
                echo "$msgprefix:Error: invalid type \`$opt_t'" 1>&2
Packit 679830
                exit 1
Packit 679830
                ;;
Packit 679830
        esac
Packit 679830
    fi
Packit 679830
Packit 679830
    #   assemble initial platform information
Packit 679830
    UNAME_MACHINE=`(uname -m) 2>/dev/null` ||\
Packit 679830
    UNAME_MACHINE=`(uname -p) 2>/dev/null` ||\
Packit 679830
    UNAME_MACHINE='unknown'
Packit 679830
    UNAME_SYSTEM=`(uname -s) 2>/dev/null`  ||\
Packit 679830
    UNAME_SYSTEM='unknown'
Packit 679830
    UNAME_RELEASE=`(uname -r) 2>/dev/null` ||\
Packit 679830
    UNAME_RELEASE=`(uname -v) 2>/dev/null` ||\
Packit 679830
    UNAME_RELEASE='unknown'
Packit 679830
Packit 679830
    UNAME="${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}"
Packit 679830
Packit 679830
    AC=""; AP=""; AT=""
Packit 679830
    SC=""; SP=""; ST=""
Packit 679830
Packit 679830
    #    dispatch into platform specific sections
Packit 679830
    case "${UNAME}" in
Packit 679830
Packit 679830
        #   FreeBSD
Packit 679830
        *:FreeBSD:* )
Packit 679830
            #   determine architecture
Packit 679830
            AC="${UNAME_MACHINE}"
Packit 679830
            case "${AC}" in
Packit 679830
                i386 ) AC="iX86" ;;
Packit 679830
            esac
Packit 679830
            AP="${AC}"
Packit 679830
            AT="${AP}"
Packit 679830
            if [ ".${AT}" = ".iX86" ]; then
Packit 679830
                case "`(/sbin/sysctl -n hw.model) 2>&1`" in
Packit 679830
                    *"Xeon"* | *"Pentium Pro"* | *"Cyrix 6x86MX"* | *"Pentium II"* | *"Pentium III"* | *"Pentium 4"* | *"Celeron"* ) AT="i686" ;;
Packit 679830
                    *"Pentium"* ) AT="i586" ;; *"i486[SD]X"* | *"Cyrix 486"* | *"Cyrix [56]x86"* | *"Blue Lightning" | *"Cyrix 486S/DX" ) AT="i486" ;;
Packit 679830
                    *"i386[SD]X"* | *"NexGen 586"* ) AT="i386" ;;
Packit 679830
                esac
Packit 679830
            fi
Packit 679830
            #   determine system
Packit 679830
            r=`echo "${UNAME_RELEASE}" |\
Packit 679830
               sed -e 's;[()];;' -e 's/\(-.*\)$/[\1]/'`
Packit 679830
            ST="FreeBSD ${r}"
Packit 679830
            SP="${ST}"
Packit 679830
            case "${r}" in
Packit 679830
                1.* ) SC="4.3BSD" ;;
Packit 679830
                *   ) SC="4.4BSD" ;;
Packit 679830
            esac
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   NetBSD
Packit 679830
        *:NetBSD:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
                i[3-6]86 ) AP="iX86" ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            r=`echo "${UNAME_RELEASE}" | sed -e 's/\([-_].*\)$/[\1]/'`
Packit 679830
            ST="NetBSD ${r}"
Packit 679830
            SP="${ST}"
Packit 679830
            case "${r}" in
Packit 679830
                0.* ) SC="4.3BSD" ;;
Packit 679830
                *   ) SC="4.4BSD" ;;
Packit 679830
            esac
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   OpenBSD
Packit 679830
        *:OpenBSD:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
                i[3-6]86 ) AP="iX86" ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            r=`echo "${UNAME_RELEASE}" | sed -e 's/\([-_].*\)$/[\1]/'`
Packit 679830
            ST="OpenBSD ${r}"
Packit 679830
            SP="${ST}"
Packit 679830
            SC="4.4BSD"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   DragonFly BSD
Packit 679830
        *:DragonFly:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
                i[3-6]86 ) AP="iX86" ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            r=`echo "${UNAME_RELEASE}" | sed -e 's/\([-_].*\)$/[\1]/'`
Packit 679830
            ST="DragonFly ${r}"
Packit 679830
            SP="${ST}"
Packit 679830
            SC="4.4BSD"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   GNU/Linux
Packit 679830
        *:Linux:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            case "${AT}" in
Packit 679830
               ia64     ) AT="IA64"   ;;
Packit 679830
               x86_64   ) AT='AMD64'  ;;
Packit 679830
               parisc   ) AT="HPPA32" ;;
Packit 679830
               parisc64 ) AT="HPPA64" ;;
Packit 679830
            esac
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
               i[3-6]86 ) AP='iX86' ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            v_kern=`echo "${UNAME_RELEASE}" |\
Packit 679830
                sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
Packit 679830
            v_libc=`(strings /lib/libc.so.* | grep '^GLIBC_' | sed -e 's/^GLIBC_//' |\
Packit 679830
                env -i sort -n | sed -n -e '$p' | sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/') 2>/dev/null`
Packit 679830
            ST="GNU/<Linux >${v_libc}/<${v_kern}>"
Packit 679830
            if [ -f /etc/lsb-release ]; then
Packit 679830
                eval `( . /etc/lsb-release
Packit 679830
                    echo "SC=\"LSB${LSB_VERSION}\""
Packit 679830
                    if [ ".${DISTRIB_ID}" != . -a ".${DISTRIB_RELEASE}" != . ]; then
Packit 679830
                        echo "SP=\"${DISTRIB_ID} ${DISTRIB_RELEASE}\""
Packit 679830
                    fi
Packit 679830
                ) 2>/dev/null`
Packit 679830
            fi
Packit 679830
            if [ ".$SP" = . ]; then
Packit 679830
                for tagfile in x \
Packit 679830
                    `cd /etc && \
Packit 679830
                    /bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \
Packit 679830
                    sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \
Packit 679830
                    echo redhat-release lsb-release`
Packit 679830
                do
Packit 679830
                    [ ".${tagfile}" = .x ] && continue
Packit 679830
                    [ ! -f "/etc/${tagfile}" ] && continue
Packit 679830
                    n=`echo ${tagfile} | sed -e 's/[_-]release$//' -e 's/[_-]version$//'`
Packit 679830
                    v=`(grep VERSION /etc/${tagfile}; cat /etc/${tagfile}) | grep '[0-9]' | sed -e 'q' |\
Packit 679830
                       sed -e 's/^/#/' \
Packit 679830
                           -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
Packit 679830
                           -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
Packit 679830
                           -e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
Packit 679830
                           -e 's/^#.*$//'`
Packit 679830
                    case "`util_lower ${n}`" in
Packit 679830
                        redhat )
Packit 679830
                            if [ ".`egrep '(Red Hat Enterprise Linux|CentOS)' /etc/${tagfile}`" != . ]; then
Packit 679830
                                n="<R>ed <H>at <E>nterprise <L>inux"
Packit 679830
                            else
Packit 679830
                                n="<R>ed <H>at <L>inux"
Packit 679830
                            fi
Packit 679830
                            ;;
Packit 679830
                        debian             ) n="Debian[ GNU/Linux]"        ;;
Packit 679830
                        ubuntu             ) n="Ubuntu[ GNU/Linux]"        ;;
Packit 679830
                        fedora             ) n="<Fedora> Core[ GNU/Linux]" ;;
Packit 679830
                        suse               ) n="[Novell ]SUSE[ Linux]"     ;;
Packit 679830
                        mandrake*|mandriva ) n="Mandriva[ Linux]"          ;;
Packit 679830
                        gentoo             ) n="Gentoo[ GNU/Linux]"        ;;
Packit 679830
                        slackware          ) n="Slackware[ Linux]"         ;;
Packit 679830
                        turbolinux         ) n="TurboLinux"                ;;
Packit 679830
                        unitedlinux        ) n="UnitedLinux"               ;;
Packit 679830
                        *                  ) n="${n}[ GNU/Linux]"          ;;
Packit 679830
                    esac
Packit 679830
                    case "$n" in
Packit 679830
                        *"<"*">"* ) SP="$n <$v>" ;;
Packit 679830
                        *         ) SP="$n $v"   ;;
Packit 679830
                    esac
Packit 679830
                    break
Packit 679830
                done
Packit 679830
            fi
Packit 679830
            [ ".$SP" = . ] && SP="${ST}"
Packit 679830
            [ ".$SC" = . ] && SC="LSB"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   Sun Solaris
Packit 679830
        *:SunOS:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            case "${AT}" in
Packit 679830
                i86pc )
Packit 679830
                    AT="iX86"
Packit 679830
                    case "`(/bin/isainfo -k) 2>&1`" in
Packit 679830
                        amd64 ) AT="AMD64" ;;
Packit 679830
                    esac
Packit 679830
                    ;;
Packit 679830
            esac
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
                sun4[cdm] ) AP="SPARC32" ;;
Packit 679830
                sun4[uv]  ) AP="SPARC64" ;;
Packit 679830
                sun4*     ) AP="SPARC"   ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            case "${AC}" in
Packit 679830
                SPARC* ) AC="SPARC" ;;
Packit 679830
            esac
Packit 679830
            #   determine system
Packit 679830
            ST="[Sun ]SunOS ${UNAME_RELEASE}"
Packit 679830
            v=`echo "${UNAME_RELEASE}" |\
Packit 679830
               sed -e 's;^4\.;1.;' \
Packit 679830
                   -e 's;^5\.\([0-6]\)[^0-9]*$;2.\1;' \
Packit 679830
                   -e 's;^5\.\([0-9][0-9]*\).*;\1;'`
Packit 679830
            SP="[Sun ]Solaris $v"
Packit 679830
            case "${UNAME_RELEASE}" in
Packit 679830
                4.* ) SC="4.3BSD" ;;
Packit 679830
                5.* ) SC="SVR4"   ;;
Packit 679830
            esac
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   SCO UnixWare
Packit 679830
        *:UnixWare:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            case "${AT}" in
Packit 679830
                i[3-6]86 | ix86at ) AT="iX86" ;;
Packit 679830
            esac
Packit 679830
            AP="${AT}"
Packit 679830
            #   determine system
Packit 679830
            v=`/sbin/uname -v`
Packit 679830
            ST="[SCO ]UnixWare ${v}"
Packit 679830
            SP="${ST}"
Packit 679830
            SC="SVR${UNAME_RELEASE}"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   QNX
Packit 679830
        *:QNX:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            case "${AT}" in
Packit 679830
                x86pc ) AT="iX86" ;;
Packit 679830
            esac
Packit 679830
            AP="${AT}"
Packit 679830
            #   determine system
Packit 679830
            v="${UNAME_RELEASE}"
Packit 679830
            ST="QNX[ Neutrino RTOS] ${v}"
Packit 679830
            v=`echo "${v}" | sed -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\).*$;\1;'`
Packit 679830
            SP="QNX[ Neutrino RTOS] ${v}"
Packit 679830
            SC="QNX"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   SGI IRIX
Packit 679830
        *:IRIX*:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}:${UNAME_SYSTEM}" in
Packit 679830
                IP*:IRIX64 ) AP="MIPS64" ;;
Packit 679830
                IP*:*      ) AP="MIPS"   ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            v=`(/bin/uname -R || /bin/uname -r) 2>/dev/null | sed -e 's;[0-9.]* ;;'`
Packit 679830
            ST="[SGI ]IRIX ${v}"
Packit 679830
            v="${UNAME_RELEASE}"
Packit 679830
            SP="[SGI ]IRIX ${v}"
Packit 679830
            SC="4.2BSD/SVR3"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   HP HP-UX
Packit 679830
        *:HP-UX:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="${UNAME_MACHINE}"
Packit 679830
            case "${AT}" in
Packit 679830
                ia64 ) AT="IA64" ;;
Packit 679830
                9000/[34]?? ) AT=M68K ;;
Packit 679830
                9000/[678][0-9][0-9])
Packit 679830
                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
Packit 679830
                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
Packit 679830
                    case "${sc_cpu_version}" in
Packit 679830
                        523 ) AT="HPPA1.0" ;;
Packit 679830
                        528 ) AT="HPPA1.1" ;;
Packit 679830
                        532 ) AT="HPPA2.0"
Packit 679830
                            case "${sc_kernel_bits}" in
Packit 679830
                                32 ) AT="${AT}n" ;;
Packit 679830
                                64 ) AT="${AT}w" ;;
Packit 679830
                            esac
Packit 679830
                            ;;
Packit 679830
                    esac
Packit 679830
                    ;;
Packit 679830
            esac
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
                HPPA* ) AP="HPPA" ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            v=`echo "${UNAME_RELEASE}" | sed -e 's;^[^0-9]*;;'`
Packit 679830
            ST="[HP ]<HP>-<UX ${v}>"
Packit 679830
            SP="${ST}"
Packit 679830
            case "${v}" in
Packit 679830
                10.*   ) SC="SVR4.2" ;;
Packit 679830
                [7-9]* ) SC="SVR4"   ;;
Packit 679830
            esac
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   HP Tru64 (OSF1)
Packit 679830
        *:OSF1:* )
Packit 679830
            #   determine architecture
Packit 679830
            AP="${UNAME_MACHINE}"
Packit 679830
            case "${AP}" in
Packit 679830
                alpha ) AP="Alpha" ;;
Packit 679830
            esac
Packit 679830
            alpha_type=`(/usr/sbin/psrinfo -v) 2>/dev/null |\
Packit 679830
                sed -n -e 's/^.*The alpha \([^ ][^ ]*\).*processor.*$/\1/p' | sed -e 'q'`
Packit 679830
            AT="${AP}${alpha_type}"
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            v=`echo "${UNAME_RELEASE}" | sed -e 's;^[VTX];;'`
Packit 679830
            ST="[HP ]Tru64 ${v}"
Packit 679830
            SP="${ST}"
Packit 679830
            SC="OSF1"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   IBM AIX
Packit 679830
        *:AIX:* )
Packit 679830
            #   determine architecture
Packit 679830
            cpu_arch=RS6000
Packit 679830
            if [ -x /usr/sbin/lsdev -a -x /usr/sbin/lsattr ]; then
Packit 679830
                cpu_id=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
Packit 679830
                if [ ".`/usr/sbin/lsattr -El ${cpu_id} | grep -i powerpc`" != . ]; then
Packit 679830
                    cpu_arch=PPC
Packit 679830
                fi
Packit 679830
            elif [ -d /QOpenSys ]; then
Packit 679830
                #   IBM i5/OS (aka OS/400) with PASE (Portable Application Solutions Environment)
Packit 679830
                cpu_arch=PPC
Packit 679830
            fi
Packit 679830
            if [ -x /usr/bin/oslevel ]; then
Packit 679830
                os_level=`/usr/bin/oslevel`
Packit 679830
            else
Packit 679830
                os_level="`uname -v`.`uname -r`"
Packit 679830
            fi
Packit 679830
            os_level=`echo "${os_level}" |\
Packit 679830
                      sed -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\)\(.*\)$;<\1>\2[\3];' \
Packit 679830
                          -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\)\(.*\)$;<\1>\2;'`
Packit 679830
            AT="${cpu_arch}"
Packit 679830
            AP="${AT}"
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            ST="[IBM ]<AIX >${os_level}"
Packit 679830
            SP="${ST}"
Packit 679830
            case "${os_level}" in
Packit 679830
                [12]* ) SC="SVR2" ;;
Packit 679830
                *     ) SC="SVR4" ;;
Packit 679830
            esac
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   Apple Mac OS X (Darwin)
Packit 679830
        *:Darwin:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="`uname -p`"
Packit 679830
            case "${AT}" in
Packit 679830
                powerpc ) AT="PPC" ;;
Packit 679830
            esac
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
                i?86 ) AP="iX86" ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            unset v1; unset v2; unset v3
Packit 679830
            eval `echo "${UNAME_RELEASE}" |\
Packit 679830
                  sed -e 's/^/#/' \
Packit 679830
                      -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"; v3="\3"/' \
Packit 679830
                      -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"/' \
Packit 679830
                      -e 's/^#\([0-9][0-9]*\).*$/v1="\1"/' \
Packit 679830
                      -e 's/^#.*$/v1="0"/'`
Packit 679830
            ST="[Apple ]<${UNAME_SYSTEM} ${v1}>${v2+.$v2}${v3+[.$v3]}"
Packit 679830
            SP="$ST"
Packit 679830
            v="`(sw_vers) 2>/dev/null | grep 'ProductVersion:' | sed -e 's/^ProductVersion:[^0-9]*\([0-9][0-9.]*\).*$/\1/'`"
Packit 679830
            if [ ".$v" = . ]; then
Packit 679830
                for name in System Server; do
Packit 679830
                    if [ -f /System/Library/CoreServices/${name}Version.plist ]; then
Packit 679830
                        v=`(defaults read "/System/Library/CoreServices/${name}Version" "ProductVersion") 2>/dev/null`
Packit 679830
                        [ ".$v" != . ] && break
Packit 679830
                    fi
Packit 679830
                done
Packit 679830
            fi
Packit 679830
            if [ ".$v" != . ]; then
Packit 679830
                unset v1; unset v2; unset v3
Packit 679830
                eval `echo "${v}" |\
Packit 679830
                      sed -e 's/^/#/' \
Packit 679830
                          -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"; v3="\3"/' \
Packit 679830
                          -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"/' \
Packit 679830
                          -e 's/^#\([0-9][0-9]*\).*$/v1="\1"/' \
Packit 679830
                          -e 's/^#.*$/v1="0"/'`
Packit 679830
                SP="[Apple ]Mac OS X ${v1}${v2+.$v2}${v3+[.$v3]}"
Packit 679830
            fi
Packit 679830
            SC="4.4BSD/Mach3.0"
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   Windows/Cygwin
Packit 679830
        *:CYGWIN*:* )
Packit 679830
            #   determine architecture
Packit 679830
            AT="`uname -m`"
Packit 679830
            AP="${AT}"
Packit 679830
            case "${AP}" in
Packit 679830
                i?86 ) AP="iX86" ;;
Packit 679830
            esac
Packit 679830
            AC="${AP}"
Packit 679830
            #   determine system
Packit 679830
            unset v1; unset v2; unset v3
Packit 679830
            eval `echo "${UNAME_RELEASE}" |\
Packit 679830
                  sed -e 's/^/#/' \
Packit 679830
                      -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"; v3="\3"/' \
Packit 679830
                      -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"/' \
Packit 679830
                      -e 's/^#\([0-9][0-9]*\).*$/v1="\1"/' \
Packit 679830
                      -e 's/^#.*$/v1="0"/'`
Packit 679830
            ST="Cygwin ${v1}${v2+.$v2}${v3+[.$v3]}"
Packit 679830
            SP="$ST"
Packit 679830
            SC="Windows"
Packit 679830
            v=`echo "${UNAME_SYSTEM}" | sed -e 's/^CYGWIN_NT-//' |\
Packit 679830
               sed -e 's/^/#/' -e 's/^#\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' -e 's/^#.*$//'`
Packit 679830
            case "$v" in
Packit 679830
                4.0 ) SC="$SC[ NT]"    ;;
Packit 679830
                5.0 ) SC="$SC[ 2000]"  ;;
Packit 679830
                5.1 ) SC="$SC[ XP]"    ;;
Packit 679830
                6.0 ) SC="$SC[ Vista]" ;;
Packit 679830
            esac
Packit 679830
            ;;
Packit 679830
Packit 679830
        #   TODO ...ADD YOUR NEW PLATFORM CHECK HERE... TODO
Packit 679830
        # *:XXX:* )
Packit 679830
        #   ...
Packit 679830
        #   ;;
Packit 679830
Packit 679830
        #   ...A STILL UNKNOWN PLATFORM...
Packit 679830
        * )
Packit 679830
            AT=`echo "${UNAME_MACHINE}" | sed -e "s; ;${opt_C};g"`
Packit 679830
            AP="${AT}"
Packit 679830
            AC="${AP}"
Packit 679830
            v=`echo "${UNAME_RELEASE}" |\
Packit 679830
               sed -e 's/^/#/' \
Packit 679830
                   -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
Packit 679830
                   -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
Packit 679830
                   -e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
Packit 679830
                   -e 's/^#.*$/?/'`
Packit 679830
            ST="${UNAME_SYSTEM} ${v}"
Packit 679830
            SP="${ST}"
Packit 679830
            SC="${SP}"
Packit 679830
            ;;
Packit 679830
Packit 679830
    esac
Packit 679830
Packit 679830
    #   provide fallback values
Packit 679830
    [ ".$AT" = . ] && AT="${AP:-${AC}}"
Packit 679830
    [ ".$AP" = . ] && AP="${AT:-${AC}}"
Packit 679830
    [ ".$AC" = . ] && AC="${AP:-${AT}}"
Packit 679830
    [ ".$ST" = . ] && ST="${SP:-${SC}}"
Packit 679830
    [ ".$SP" = . ] && SP="${ST:-${SC}}"
Packit 679830
    [ ".$SC" = . ] && SC="${SP:-${ST}}"
Packit 679830
Packit 679830
    #   support explicit enforced verbose/concise output
Packit 679830
    if [ ".$opt_v" = .yes ]; then
Packit 679830
        opt_F=`echo ":$opt_F" | sed -e 's/^://' -e 's/%\([as][cpt]\)/%[\1]/g'`
Packit 679830
    elif [ ".$opt_c" = .yes ]; then
Packit 679830
        opt_F=`echo ":$opt_F" | sed -e 's/^://' -e 's/%\([as][cpt]\)/%<\1>/g'`
Packit 679830
    fi
Packit 679830
Packit 679830
    #   provide verbose and concise variants
Packit 679830
    AC_V=""; AC_N=""; AC_C=""
Packit 679830
    AP_V=""; AP_N=""; AP_C=""
Packit 679830
    AT_V=""; AT_N=""; AT_C=""
Packit 679830
    SC_V=""; SC_N=""; SC_C=""
Packit 679830
    SP_V=""; SP_N=""; SP_C=""
Packit 679830
    ST_V=""; ST_N=""; ST_C=""
Packit 679830
    for var_lc in at ap ac st sp sc; do
Packit 679830
        case "$opt_F" in
Packit 679830
            *"%[${val_lc}]"* | *"%{${val_lc}}"* | *"%${val_lc}"* | *"%<${val_lc}>"* )
Packit 679830
            var_uc=`util_upper "$var_lc"`
Packit 679830
            eval "val=\"\$${var_uc}\""
Packit 679830
            val_V=""; val_N=""; val_C=""
Packit 679830
            case "$opt_F" in
Packit 679830
                *"%[${var_lc}]"* )
Packit 679830
                    val_V=`echo ":$val" | \
Packit 679830
                           sed -e 's/^://' \
Packit 679830
                               -e 's;\[\([^]]*\)\];\1;g' \
Packit 679830
                               -e 's;<\([^>]*\)>;\1;g' \
Packit 679830
                               -e "s; ;§§;g" \
Packit 679830
                               -e "s;/;%%;g" \
Packit 679830
                               -e "s;§§;${opt_S};g" \
Packit 679830
                               -e "s;%%;${opt_C};g"`
Packit 679830
                    eval "${var_uc}_V=\"\${val_V}\""
Packit 679830
                    ;;
Packit 679830
            esac
Packit 679830
            case "$opt_F" in
Packit 679830
                *"%{${var_lc}}"* | *"%${var_lc}"* )
Packit 679830
                    val_N=`echo ":$val" | \
Packit 679830
                           sed -e 's/^://' \
Packit 679830
                               -e 's;\[\([^]]*\)\];;g' \
Packit 679830
                               -e 's;<\([^>]*\)>;\1;g' \
Packit 679830
                               -e "s; ;§§;g" \
Packit 679830
                               -e "s;/;%%;g" \
Packit 679830
                               -e "s;§§;${opt_S};g" \
Packit 679830
                               -e "s;%%;${opt_C};g"`
Packit 679830
                    eval "${var_uc}_N=\"\${val_N}\""
Packit 679830
                    ;;
Packit 679830
            esac
Packit 679830
            case "$opt_F" in
Packit 679830
                *"%<${var_lc}>"* )
Packit 679830
                    val_C=`echo ":$val" | \
Packit 679830
                           sed -e 's/^://' \
Packit 679830
                               -e 's;\[\([^]]*\)\];;g' \
Packit 679830
                               -e 's;[^<]*<\([^>]*\)>[^<]*;\1;g' \
Packit 679830
                               -e "s; ;§§;g" \
Packit 679830
                               -e "s;/;%%;g" \
Packit 679830
                               -e "s;§§;${opt_S};g" \
Packit 679830
                               -e "s;%%;${opt_C};g"`
Packit 679830
                    eval "${var_uc}_C=\"\${val_C}\""
Packit 679830
                    ;;
Packit 679830
            esac
Packit 679830
            ;;
Packit 679830
        esac
Packit 679830
    done
Packit 679830
Packit 679830
    #   create output string
Packit 679830
    output=`echo ":$opt_F" |\
Packit 679830
            sed -e "s/^://" \
Packit 679830
                -e "s;%\\[ac\\];${AC_V};g" \
Packit 679830
                -e "s;%{ac};${AC_N};g" \
Packit 679830
                -e "s;%ac;${AC_N};g" \
Packit 679830
                -e "s;%<ac>;${AC_C};g" \
Packit 679830
                -e "s;%\\[ap\\];${AP_V};g" \
Packit 679830
                -e "s;%{ap};${AP_N};g" \
Packit 679830
                -e "s;%ap;${AP_N};g" \
Packit 679830
                -e "s;%<ap>;${AP_C};g" \
Packit 679830
                -e "s;%\\[at\\];${AT_V};g" \
Packit 679830
                -e "s;%{at};${AT_N};g" \
Packit 679830
                -e "s;%at;${AT_N};g" \
Packit 679830
                -e "s;%<at>;${AT_C};g" \
Packit 679830
                -e "s;%\\[sc\\];${SC_V};g" \
Packit 679830
                -e "s;%{sc};${SC_N};g" \
Packit 679830
                -e "s;%sc;${SC_N};g" \
Packit 679830
                -e "s;%<sc>;${SC_C};g" \
Packit 679830
                -e "s;%\\[sp\\];${SP_V};g" \
Packit 679830
                -e "s;%{sp};${SP_N};g" \
Packit 679830
                -e "s;%sp;${SP_N};g" \
Packit 679830
                -e "s;%<sp>;${SP_C};g" \
Packit 679830
                -e "s;%\\[st\\];${ST_V};g" \
Packit 679830
                -e "s;%{st};${ST_N};g" \
Packit 679830
                -e "s;%st;${ST_N};g" \
Packit 679830
                -e "s;%<st>;${ST_C};g" \
Packit 679830
                -e 's/\\\\n/^/g' |\
Packit 679830
             tr '^' '\012'`
Packit 679830
Packit 679830
    #   support lower/upper-case mapping
Packit 679830
    if [ ".$opt_L" = .yes ]; then
Packit 679830
        output=`util_lower "$output"`
Packit 679830
    elif [ ".$opt_U" = .yes ]; then
Packit 679830
        output=`util_upper "$output"`
Packit 679830
    fi
Packit 679830
Packit 679830
    #   display output string
Packit 679830
    if [ ".$opt_n" = .yes ]; then
Packit 679830
        echo . | awk '{ printf("%s", output); }' output="$output"
Packit 679830
    else
Packit 679830
        echo "$output"
Packit 679830
    fi
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
arx )
Packit 679830
    ##
Packit 679830
    ##  arx -- Extended archive command
Packit 679830
    ##  Copyright (c) 1999-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    ar_prg="$opt_C"
Packit 679830
    ar_cmd="$1"; shift
Packit 679830
    archive="$1"; shift
Packit 679830
    files="$*"
Packit 679830
Packit 679830
    #   walk through the file list and expand archives members
Packit 679830
    ar_tmpdir=`echo $archive | sed -e 's;[^/]*$;.arx;'`
Packit 679830
    nfiles=''
Packit 679830
    if [ ".$files" != . ]; then
Packit 679830
        for file in $files; do
Packit 679830
            if [ ! -f $file ]; then
Packit 679830
                echo "$msgprefix:Error: input file not found: $file" 1>&2
Packit 679830
                shtool_exit 1
Packit 679830
            fi
Packit 679830
            case $file in
Packit 679830
                *.a )
Packit 679830
                    if [ ! -d $ar_tmpdir ]; then
Packit 679830
                        if [ ".$opt_t" = .yes ]; then
Packit 679830
                            echo "mkdir $ar_tmpdir" 1>&2
Packit 679830
                        fi
Packit 679830
                        mkdir $ar_tmpdir
Packit 679830
                    fi
Packit 679830
                    case $ar_tmpdir in
Packit 679830
                         .arx )
Packit 679830
                             from="../$file"
Packit 679830
                             ;;
Packit 679830
                         * )
Packit 679830
                             dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;'`
Packit 679830
                             base=`echo $file | sed -e 's;.*/\([^/]*\)$;\1;'`
Packit 679830
                             from="`cd $dir; pwd`/$base"
Packit 679830
                             ;;
Packit 679830
                    esac
Packit 679830
                    if [ ".$opt_t" = .yes ]; then
Packit 679830
                        echo "(cd $ar_tmpdir && $ar_prg x $from)" 1>&2
Packit 679830
                    fi
Packit 679830
                    (cd $ar_tmpdir && eval $ar_prg x $from)
Packit 679830
                    if [ $? -ne 0 ]; then
Packit 679830
                        echo "$msgprefix:Error: member extraction failed for archive: $file" 1>&2
Packit 679830
                        shtool_exit 1
Packit 679830
                    fi
Packit 679830
                    for member in - `eval $ar_prg t $file | sed -e '/_\.SYMDEF/d'`; do
Packit 679830
                        [ ".$member" = .- ] && continue
Packit 679830
                        nfiles="$nfiles $ar_tmpdir/$member"
Packit 679830
                    done
Packit 679830
                    ;;
Packit 679830
                * )
Packit 679830
                    nfiles="$nfiles $file"
Packit 679830
                    ;;
Packit 679830
            esac
Packit 679830
        done
Packit 679830
    fi
Packit 679830
Packit 679830
    #   run the final archive command
Packit 679830
    if [ ".$opt_t" = .yes ]; then
Packit 679830
        echo "$ar_prg $ar_cmd $archive $nfiles" 1>&2
Packit 679830
    fi
Packit 679830
    eval $ar_prg $ar_cmd $archive $nfiles
Packit 679830
    if [ $? -ne 0 ]; then
Packit 679830
        echo "$msgprefix:Error: archive command failed" 1>&2
Packit 679830
        shtool_exit $?
Packit 679830
    fi
Packit 679830
Packit 679830
    #   cleanup and die gracefully
Packit 679830
    if [ -d $ar_tmpdir ]; then
Packit 679830
        if [ ".$opt_t" = .yes ]; then
Packit 679830
            echo "rm -rf $ar_tmpdir" 1>&2
Packit 679830
        fi
Packit 679830
        rm -rf $ar_tmpdir
Packit 679830
    fi
Packit 679830
Packit 679830
    shtool_exit 0
Packit 679830
    ;;
Packit 679830
Packit 679830
slo )
Packit 679830
    ##
Packit 679830
    ##  slo -- Separate linker options by library class
Packit 679830
    ##  Copyright (c) 1998-2008 Ralf S. Engelschall <rse@engelschall.com>
Packit 679830
    ##
Packit 679830
Packit 679830
    DIFS="$IFS"
Packit 679830
Packit 679830
    #   parse out -L and -l options from command line
Packit 679830
    DIRS=''
Packit 679830
    LIBS=''
Packit 679830
    ARGV=''
Packit 679830
    optprev=''
Packit 679830
    for opt
Packit 679830
    do
Packit 679830
        #   concatenate with previous option if exists
Packit 679830
        if [ ".$optprev" != . ]; then
Packit 679830
            opt="${optprev}${opt}";
Packit 679830
            optprev=''
Packit 679830
        fi
Packit 679830
        #   remember options for arg if used stand-alone
Packit 679830
        if [ ".$opt" = ".-L" ] || [ ".$opt" = ".-l" ]; then
Packit 679830
            optprev="$opt"
Packit 679830
            continue;
Packit 679830
        fi
Packit 679830
        #   split argument into option plus option argument
Packit 679830
        arg="`echo $opt | cut -c3-`"
Packit 679830
        opt="`echo $opt | cut -c1-2`"
Packit 679830
        #   store into containers
Packit 679830
        case $opt in
Packit 679830
            -L) DIRS="$DIRS:$arg" ;;
Packit 679830
            -l) LIBS="$LIBS:$arg" ;;
Packit 679830
             *) ARGV="$ARGV $opt" ;;
Packit 679830
        esac
Packit 679830
    done
Packit 679830
Packit 679830
    #   set linker default directories
Packit 679830
    DIRS_DEFAULT='/lib:/usr/lib'
Packit 679830
    if [ ".$LD_LIBRARY_PATH" != . ]; then
Packit 679830
        DIRS_DEFAULT="$DIRS_DEFAULT:$LD_LIBRARY_PATH"
Packit 679830
    fi
Packit 679830
Packit 679830
    #   sort options by class
Packit 679830
    DIRS_OBJ=''
Packit 679830
    LIBS_OBJ=''
Packit 679830
    DIRS_PIC=''
Packit 679830
    LIBS_PIC=''
Packit 679830
    DIRS_DSO=''
Packit 679830
    LIBS_DSO=''
Packit 679830
Packit 679830
    #    for each library...
Packit 679830
    OIFS="$IFS"; IFS=':'
Packit 679830
    for lib in $LIBS; do
Packit 679830
        [ ".$lib" = . ] && continue
Packit 679830
Packit 679830
        found='no'
Packit 679830
        found_indefdir='no'
Packit 679830
        found_type=''
Packit 679830
        found_dir=''
Packit 679830
Packit 679830
        #    for each directory...
Packit 679830
        OIFS2="$IFS"; IFS=":$DIFS"
Packit 679830
        for dir in ${DIRS} switch-to-defdirs ${DIRS_DEFAULT}; do