1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/openpkg/shtool Tue Jan 06 23:40:39 2009 +0100 1.3 @@ -0,0 +1,4037 @@ 1.4 +#!/bin/sh 1.5 +## 1.6 +## GNU shtool -- The GNU Portable Shell Tool 1.7 +## Copyright (c) 1994-2007 Ralf S. Engelschall <rse@engelschall.com> 1.8 +## 1.9 +## See http://www.gnu.org/software/shtool/ for more information. 1.10 +## See ftp://ftp.gnu.org/gnu/shtool/ for latest version. 1.11 +## 1.12 +## Version: 2.0.7 (19-May-2007) 1.13 +## Contents: all available modules 1.14 +## 1.15 + 1.16 +## 1.17 +## This program is free software; you can redistribute it and/or modify 1.18 +## it under the terms of the GNU General Public License as published by 1.19 +## the Free Software Foundation; either version 2 of the License, or 1.20 +## (at your option) any later version. 1.21 +## 1.22 +## This program is distributed in the hope that it will be useful, 1.23 +## but WITHOUT ANY WARRANTY; without even the implied warranty of 1.24 +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1.25 +## General Public License for more details. 1.26 +## 1.27 +## You should have received a copy of the GNU General Public License 1.28 +## along with this program; if not, write to the Free Software 1.29 +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 1.30 +## USA, or contact Ralf S. Engelschall <rse@engelschall.com>. 1.31 +## 1.32 +## NOTICE: Given that you include this file verbatim into your own 1.33 +## source tree, you are justified in saying that it remains separate 1.34 +## from your package, and that this way you are simply just using GNU 1.35 +## shtool. So, in this situation, there is no requirement that your 1.36 +## package itself is licensed under the GNU General Public License in 1.37 +## order to take advantage of GNU shtool. 1.38 +## 1.39 + 1.40 +## 1.41 +## Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]] 1.42 +## 1.43 +## Available commands: 1.44 +## echo Print string with optional construct expansion 1.45 +## mdate Pretty-print modification time of a file or dir 1.46 +## table Pretty-print a field-separated list as a table 1.47 +## prop Display progress with a running propeller 1.48 +## move Move files with simultaneous substitution 1.49 +## install Install a program, script or datafile 1.50 +## mkdir Make one or more directories 1.51 +## mkln Make link with calculation of relative paths 1.52 +## mkshadow Make a shadow tree through symbolic links 1.53 +## fixperm Fix file permissions inside a source tree 1.54 +## rotate Logfile rotation 1.55 +## tarball Roll distribution tarballs 1.56 +## subst Apply sed(1) substitution operations 1.57 +## platform Platform Identification Utility 1.58 +## arx Extended archive command 1.59 +## slo Separate linker options by library class 1.60 +## scpp Sharing C Pre-Processor 1.61 +## version Maintain a version information file 1.62 +## path Deal with program paths 1.63 +## 1.64 + 1.65 +# maximum Bourne-Shell compatibility 1.66 +if [ ".$ZSH_VERSION" != . ] && (emulate sh) >/dev/null 2>&1; then 1.67 + # reconfigure zsh(1) 1.68 + emulate sh 1.69 + NULLCMD=: 1.70 + alias -g '${1+"$@"}'='"$@"' 1.71 +elif [ ".$BASH_VERSION" != . ] && (set -o posix) >/dev/null 2>&1; then 1.72 + # reconfigure bash(1) 1.73 + set -o posix 1.74 +fi 1.75 + 1.76 +# maximum independence of NLS nuisances 1.77 +for var in \ 1.78 + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ 1.79 + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ 1.80 + LC_TELEPHONE LC_TIME 1.81 +do 1.82 + if (set +x; test -z "`(eval $var=C; export $var) 2>&1`"); then 1.83 + eval $var=C; export $var 1.84 + else 1.85 + unset $var 1.86 + fi 1.87 +done 1.88 + 1.89 +# initial command line handling 1.90 +if [ $# -eq 0 ]; then 1.91 + echo "$0:Error: invalid command line" 1>&2 1.92 + echo "$0:Hint: run \`$0 -h' for usage" 1>&2 1.93 + exit 1 1.94 +fi 1.95 +if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then 1.96 + echo "This is GNU shtool, version 2.0.7 (19-May-2007)" 1.97 + echo 'Copyright (c) 1994-2007 Ralf S. Engelschall <rse@engelschall.com>' 1.98 + echo 'Report bugs to <bug-shtool@gnu.org>' 1.99 + echo '' 1.100 + echo 'Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]' 1.101 + echo '' 1.102 + echo 'Available global <options>:' 1.103 + echo ' -v, --version display shtool version information' 1.104 + echo ' -h, --help display shtool usage help page (this one)' 1.105 + echo ' -d, --debug display shell trace information' 1.106 + echo ' -r, --recreate recreate this shtool script via shtoolize' 1.107 + echo '' 1.108 + echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:' 1.109 + echo ' echo [-n|--newline] [-e|--expand] [<string> ...]' 1.110 + echo ' mdate [-n|--newline] [-z|--zero] [-s|--shorten] [-d|--digits]' 1.111 + echo ' [-f|--field-sep <str>] [-o|--order <spec>] <path>' 1.112 + echo ' table [-F|--field-sep <sep>] [-w|--width <width>] [-c|--columns' 1.113 + echo ' <cols>] [-s|--strip <strip>] <str><sep><str>...' 1.114 + echo ' prop [-p|--prefix <str>]' 1.115 + echo ' move [-v|--verbose] [-t|--trace] [-e|--expand] [-p|--preserve]' 1.116 + echo ' <src-file> <dst-file>' 1.117 + echo ' install [-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy]' 1.118 + echo ' [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>]' 1.119 + echo ' [-o|--owner <owner>] [-g|--group <group>] [-e|--exec' 1.120 + echo ' <sed-cmd>] <file> [<file> ...] <path>' 1.121 + echo ' mkdir [-t|--trace] [-f|--force] [-p|--parents] [-m|--mode' 1.122 + echo ' <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir>' 1.123 + echo ' [<dir> ...]' 1.124 + echo ' mkln [-t|--trace] [-f|--force] [-s|--symbolic] <src-path>' 1.125 + echo ' [<src-path> ...] <dst-path>' 1.126 + echo ' mkshadow [-v|--verbose] [-t|--trace] [-a|--all] <src-dir> <dst-dir>' 1.127 + echo ' fixperm [-v|--verbose] [-t|--trace] <path> [<path> ...]' 1.128 + echo ' rotate [-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files' 1.129 + echo ' <count>] [-s|--size <size>] [-c|--copy] [-r|--remove]' 1.130 + echo ' [-a|--archive-dir <dir>] [-z|--compress [<tool>:]<level>]' 1.131 + echo ' [-b|--background] [-d|--delay] [-p|--pad <len>] [-m|--mode' 1.132 + echo ' <mode>] [-o|--owner <owner>] [-g|--group <group>] [-M|--migrate' 1.133 + echo ' <cmd>] [-P|--prolog <cmd>] [-E|--epilog <cmd>] <file> [...]' 1.134 + echo ' tarball [-t|--trace] [-v|--verbose] [-o|--output <tarball>]' 1.135 + echo ' [-c|--compress <prog>] [-d|--directory <dir>] [-u|--user' 1.136 + echo ' <user>] [-g|--group <group>] [-e|--exclude <pattern>]' 1.137 + echo ' <path> [<path> ...]' 1.138 + echo ' subst [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning]' 1.139 + echo ' [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup' 1.140 + echo ' <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>]' 1.141 + echo ' [...]' 1.142 + echo ' platform [-F|--format <format>] [-S|--sep <string>] [-C|--conc' 1.143 + echo ' <string>] [-L|--lower] [-U|--upper] [-v|--verbose]' 1.144 + echo ' [-c|--concise] [-n|--no-newline] [-t|--type <type>]' 1.145 + echo ' [-V|--version] [-h|--help]' 1.146 + echo ' arx [-t|--trace] [-C|--command <cmd>] <op> <archive> [<file>' 1.147 + echo ' ...]' 1.148 + echo ' slo [-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib>' 1.149 + echo ' ...]' 1.150 + echo ' scpp [-v|--verbose] [-p|--preserve] [-f|--filter <filter>]' 1.151 + echo ' [-o|--output <ofile>] [-t|--template <tfile>] [-M|--mark' 1.152 + echo ' <mark>] [-D|--define <dname>] [-C|--class <cname>]' 1.153 + echo ' <file> [<file> ...]' 1.154 + echo ' version [-l|--language <lang>] [-n|--name <name>] [-p|--prefix' 1.155 + echo ' <prefix>] [-s|--set <version>] [-e|--edit] [-i|--increase' 1.156 + echo ' <knob>] [-d|--display <type>] <file>' 1.157 + echo ' path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename]' 1.158 + echo ' [-m|--magic] [-p|--path <path>] <str> [<str> ...]' 1.159 + echo '' 1.160 + exit 0 1.161 +fi 1.162 +if [ ".$1" = ".-v" ] || [ ".$1" = ".--version" ]; then 1.163 + echo "GNU shtool 2.0.7 (19-May-2007)" 1.164 + exit 0 1.165 +fi 1.166 +if [ ".$1" = ".-r" ] || [ ".$1" = ".--recreate" ]; then 1.167 + shtoolize -oshtool all 1.168 + exit 0 1.169 +fi 1.170 +if [ ".$1" = ".-d" ] || [ ".$1" = ".--debug" ]; then 1.171 + shift 1.172 + set -x 1.173 +fi 1.174 +name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'` 1.175 +case "$name" in 1.176 + echo|mdate|table|prop|move|install|mkdir|mkln|mkshadow|fixperm|rotate|tarball|subst|platform|arx|slo|scpp|version|path ) 1.177 + # implicit tool command selection 1.178 + tool="$name" 1.179 + ;; 1.180 + * ) 1.181 + # explicit tool command selection 1.182 + tool="$1" 1.183 + shift 1.184 + ;; 1.185 +esac 1.186 +arg_spec="" 1.187 +opt_spec="" 1.188 +gen_tmpfile=no 1.189 + 1.190 +## 1.191 +## DISPATCH INTO SCRIPT PROLOG 1.192 +## 1.193 + 1.194 +case $tool in 1.195 + echo ) 1.196 + str_tool="echo" 1.197 + str_usage="[-n|--newline] [-e|--expand] [<string> ...]" 1.198 + arg_spec="0+" 1.199 + opt_spec="n.e." 1.200 + opt_alias="n:newline,e:expand" 1.201 + opt_n=no 1.202 + opt_e=no 1.203 + ;; 1.204 + mdate ) 1.205 + str_tool="mdate" 1.206 + str_usage="[-n|--newline] [-z|--zero] [-s|--shorten] [-d|--digits] [-f|--field-sep <str>] [-o|--order <spec>] <path>" 1.207 + arg_spec="1=" 1.208 + opt_spec="n.z.s.d.f:o:" 1.209 + opt_alias="n:newline,z:zero,s:shorten,d:digits,f:field-sep,o:order" 1.210 + opt_n=no 1.211 + opt_z=no 1.212 + opt_s=no 1.213 + opt_d=no 1.214 + opt_f=" " 1.215 + opt_o="dmy" 1.216 + ;; 1.217 + table ) 1.218 + str_tool="table" 1.219 + str_usage="[-F|--field-sep <sep>] [-w|--width <width>] [-c|--columns <cols>] [-s|--strip <strip>] <str><sep><str>..." 1.220 + arg_spec="1+" 1.221 + opt_spec="F:w:c:s:" 1.222 + opt_alias="F:field-sep,w:width,c:columns,s:strip" 1.223 + opt_F=":" 1.224 + opt_w=15 1.225 + opt_c=3 1.226 + opt_s=79 1.227 + ;; 1.228 + prop ) 1.229 + str_tool="prop" 1.230 + str_usage="[-p|--prefix <str>]" 1.231 + arg_spec="0=" 1.232 + opt_spec="p:" 1.233 + opt_alias="p:prefix" 1.234 + opt_p="" 1.235 + ;; 1.236 + move ) 1.237 + str_tool="move" 1.238 + str_usage="[-v|--verbose] [-t|--trace] [-e|--expand] [-p|--preserve] <src-file> <dst-file>" 1.239 + arg_spec="2=" 1.240 + opt_spec="v.t.e.p." 1.241 + opt_alias="v:verbose,t:trace,e:expand,p:preserve" 1.242 + opt_v=no 1.243 + opt_t=no 1.244 + opt_e=no 1.245 + opt_p=no 1.246 + ;; 1.247 + install ) 1.248 + str_tool="install" 1.249 + 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>" 1.250 + arg_spec="1+" 1.251 + opt_spec="v.t.d.c.C.s.m:o:g:e+" 1.252 + opt_alias="v:verbose,t:trace,d:mkdir,c:copy,C:compare-copy,s:strip,m:mode,o:owner,g:group,e:exec" 1.253 + opt_v=no 1.254 + opt_t=no 1.255 + opt_d=no 1.256 + opt_c=no 1.257 + opt_C=no 1.258 + opt_s=no 1.259 + opt_m="0755" 1.260 + opt_o="" 1.261 + opt_g="" 1.262 + opt_e="" 1.263 + ;; 1.264 + mkdir ) 1.265 + str_tool="mkdir" 1.266 + str_usage="[-t|--trace] [-f|--force] [-p|--parents] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir> [<dir> ...]" 1.267 + arg_spec="1+" 1.268 + opt_spec="t.f.p.m:o:g:" 1.269 + opt_alias="t:trace,f:force,p:parents,m:mode,o:owner,g:group" 1.270 + opt_t=no 1.271 + opt_f=no 1.272 + opt_p=no 1.273 + opt_m="" 1.274 + opt_o="" 1.275 + opt_g="" 1.276 + ;; 1.277 + mkln ) 1.278 + str_tool="mkln" 1.279 + str_usage="[-t|--trace] [-f|--force] [-s|--symbolic] <src-path> [<src-path> ...] <dst-path>" 1.280 + arg_spec="2+" 1.281 + opt_spec="t.f.s." 1.282 + opt_alias="t:trace,f:force,s:symbolic" 1.283 + opt_t=no 1.284 + opt_f=no 1.285 + opt_s=no 1.286 + ;; 1.287 + mkshadow ) 1.288 + str_tool="mkshadow" 1.289 + str_usage="[-v|--verbose] [-t|--trace] [-a|--all] <src-dir> <dst-dir>" 1.290 + arg_spec="2=" 1.291 + opt_spec="v.t.a." 1.292 + opt_alias="v:verbose,t:trace,a:all" 1.293 + opt_v=no 1.294 + opt_t=no 1.295 + opt_a=no 1.296 + ;; 1.297 + fixperm ) 1.298 + str_tool="fixperm" 1.299 + str_usage="[-v|--verbose] [-t|--trace] <path> [<path> ...]" 1.300 + arg_spec="1+" 1.301 + opt_spec="v.t." 1.302 + opt_alias="v:verbose,t:trace" 1.303 + opt_v=no 1.304 + opt_t=no 1.305 + ;; 1.306 + rotate ) 1.307 + str_tool="rotate" 1.308 + 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> [...]" 1.309 + arg_spec="1+" 1.310 + opt_spec="v.t.f.n:s:c.r.a:z:b.d.p:o:g:m:M:P:E:" 1.311 + 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" 1.312 + opt_v=no 1.313 + opt_t=no 1.314 + opt_f=no 1.315 + opt_n=10 1.316 + opt_s="" 1.317 + opt_c=no 1.318 + opt_r=no 1.319 + opt_a="" 1.320 + opt_z="" 1.321 + opt_b=no 1.322 + opt_d=no 1.323 + opt_p=1 1.324 + opt_o="" 1.325 + opt_g="" 1.326 + opt_m="" 1.327 + opt_M="" 1.328 + opt_P="" 1.329 + opt_E="" 1.330 + ;; 1.331 + tarball ) 1.332 + str_tool="tarball" 1.333 + 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> ...]" 1.334 + gen_tmpfile=yes 1.335 + arg_spec="1+" 1.336 + opt_spec="t.v.o:c:d:u:g:e:" 1.337 + opt_alias="t:trace,v:verbose,o:output,c:compress,d:directory,u:user,g:group,e:exclude" 1.338 + opt_t=no 1.339 + opt_v=no 1.340 + opt_o="" 1.341 + opt_c="" 1.342 + opt_d="" 1.343 + opt_u="" 1.344 + opt_g="" 1.345 + opt_e="CVS,\\.cvsignore,\\.svn,\\.[oa]\$" 1.346 + ;; 1.347 + subst ) 1.348 + str_tool="subst" 1.349 + 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>] [...]" 1.350 + gen_tmpfile=yes 1.351 + arg_spec="0+" 1.352 + opt_spec="v.t.n.w.q.s.i.b:e+f:" 1.353 + opt_alias="v:verbose,t:trace,n:nop,w:warning,q:quiet,s:stealth,i:interactive,b:backup,e:exec,f:file" 1.354 + opt_v=no 1.355 + opt_t=no 1.356 + opt_n=no 1.357 + opt_w=no 1.358 + opt_q=no 1.359 + opt_s=no 1.360 + opt_i=no 1.361 + opt_b="" 1.362 + opt_e="" 1.363 + opt_f="" 1.364 + ;; 1.365 + platform ) 1.366 + str_tool="platform" 1.367 + 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]" 1.368 + arg_spec="0=" 1.369 + opt_spec="F:S:C:L.U.v.c.n.t:d.V.h." 1.370 + 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" 1.371 + opt_F="%{sp} (%{ap})" 1.372 + opt_S=" " 1.373 + opt_C="/" 1.374 + opt_L=no 1.375 + opt_U=no 1.376 + opt_t="" 1.377 + opt_v=no 1.378 + opt_c=no 1.379 + opt_n=no 1.380 + opt_V=no 1.381 + opt_h=no 1.382 + ;; 1.383 + arx ) 1.384 + str_tool="arx" 1.385 + str_usage="[-t|--trace] [-C|--command <cmd>] <op> <archive> [<file> ...]" 1.386 + arg_spec="2+" 1.387 + opt_spec="t.C:" 1.388 + opt_alias="t:trace,C:command" 1.389 + opt_t=no 1.390 + opt_C="ar" 1.391 + ;; 1.392 + slo ) 1.393 + str_tool="slo" 1.394 + str_usage="[-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib> ...]" 1.395 + arg_spec="1+" 1.396 + opt_spec="p:" 1.397 + opt_alias="p:prefix" 1.398 + opt_p="SLO_" 1.399 + ;; 1.400 + scpp ) 1.401 + str_tool="scpp" 1.402 + 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> ...]" 1.403 + gen_tmpfile=yes 1.404 + arg_spec="1+" 1.405 + opt_spec="v.p.f+o:t:M:D:C:" 1.406 + opt_alias="v:verbose,p:preserve,f:filter,o:output,t:template,M:mark,D:define,C:class" 1.407 + opt_v=no 1.408 + opt_p=no 1.409 + opt_f="" 1.410 + opt_o="lib.h" 1.411 + opt_t="lib.h.in" 1.412 + opt_M="%%MARK%%" 1.413 + opt_D="cpp" 1.414 + opt_C="intern" 1.415 + ;; 1.416 + version ) 1.417 + str_tool="version" 1.418 + str_usage="[-l|--language <lang>] [-n|--name <name>] [-p|--prefix <prefix>] [-s|--set <version>] [-e|--edit] [-i|--increase <knob>] [-d|--display <type>] <file>" 1.419 + arg_spec="1=" 1.420 + opt_spec="l:n:p:s:i:e.d:" 1.421 + opt_alias="l:language,n:name,p:prefix,s:set,e:edit,i:increase,d:display" 1.422 + opt_l="txt" 1.423 + opt_n="unknown" 1.424 + opt_p="" 1.425 + opt_s="" 1.426 + opt_e="no" 1.427 + opt_i="" 1.428 + opt_d="short" 1.429 + ;; 1.430 + path ) 1.431 + str_tool="path" 1.432 + str_usage="[-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path <path>] <str> [<str> ...]" 1.433 + gen_tmpfile=yes 1.434 + arg_spec="1+" 1.435 + opt_spec="s.r.d.b.m.p:" 1.436 + opt_alias="s:suppress,r:reverse,d:dirname,b:basename,m:magic,p:path" 1.437 + opt_s=no 1.438 + opt_r=no 1.439 + opt_d=no 1.440 + opt_b=no 1.441 + opt_m=no 1.442 + opt_p="$PATH" 1.443 + ;; 1.444 + -* ) 1.445 + echo "$0:Error: unknown option \`$tool'" 2>&1 1.446 + echo "$0:Hint: run \`$0 -h' for usage" 2>&1 1.447 + exit 1 1.448 + ;; 1.449 + * ) 1.450 + echo "$0:Error: unknown command \`$tool'" 2>&1 1.451 + echo "$0:Hint: run \`$0 -h' for usage" 2>&1 1.452 + exit 1 1.453 + ;; 1.454 +esac 1.455 + 1.456 +## 1.457 +## COMMON UTILITY CODE 1.458 +## 1.459 + 1.460 +# commonly used ASCII values 1.461 +ASC_TAB=" " 1.462 +ASC_NL=" 1.463 +" 1.464 + 1.465 +# determine name of tool 1.466 +if [ ".$tool" != . ]; then 1.467 + # used inside shtool script 1.468 + toolcmd="$0 $tool" 1.469 + toolcmdhelp="shtool $tool" 1.470 + msgprefix="shtool:$tool" 1.471 +else 1.472 + # used as standalone script 1.473 + toolcmd="$0" 1.474 + toolcmdhelp="sh $0" 1.475 + msgprefix="$str_tool" 1.476 +fi 1.477 + 1.478 +# parse argument specification string 1.479 +eval `echo $arg_spec |\ 1.480 + sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'` 1.481 + 1.482 +# parse option specification string 1.483 +eval `echo h.$opt_spec |\ 1.484 + sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'` 1.485 + 1.486 +# parse option alias string 1.487 +eval `echo h:help,$opt_alias |\ 1.488 + sed -e 's/-/_/g' -e 's/\([a-zA-Z0-9]\):\([^,]*\),*/opt_ALIAS_\2=\1;/g'` 1.489 + 1.490 +# interate over argument line 1.491 +opt_PREV='' 1.492 +while [ $# -gt 0 ]; do 1.493 + # special option stops processing 1.494 + if [ ".$1" = ".--" ]; then 1.495 + shift 1.496 + break 1.497 + fi 1.498 + 1.499 + # determine option and argument 1.500 + opt_ARG_OK=no 1.501 + if [ ".$opt_PREV" != . ]; then 1.502 + # merge previous seen option with argument 1.503 + opt_OPT="$opt_PREV" 1.504 + opt_ARG="$1" 1.505 + opt_ARG_OK=yes 1.506 + opt_PREV='' 1.507 + else 1.508 + # split argument into option and argument 1.509 + case "$1" in 1.510 + --[a-zA-Z0-9]*=*) 1.511 + eval `echo "x$1" |\ 1.512 + sed -e 's/^x--\([a-zA-Z0-9-]*\)=\(.*\)$/opt_OPT="\1";opt_ARG="\2"/'` 1.513 + opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'` 1.514 + eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}" 1.515 + ;; 1.516 + --[a-zA-Z0-9]*) 1.517 + opt_OPT=`echo "x$1" | cut -c4-` 1.518 + opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'` 1.519 + eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}" 1.520 + opt_ARG='' 1.521 + ;; 1.522 + -[a-zA-Z0-9]*) 1.523 + eval `echo "x$1" |\ 1.524 + sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \ 1.525 + -e 's/";\(.*\)$/"; opt_ARG="\1"/'` 1.526 + ;; 1.527 + -[a-zA-Z0-9]) 1.528 + opt_OPT=`echo "x$1" | cut -c3-` 1.529 + opt_ARG='' 1.530 + ;; 1.531 + *) 1.532 + break 1.533 + ;; 1.534 + esac 1.535 + fi 1.536 + 1.537 + # eat up option 1.538 + shift 1.539 + 1.540 + # determine whether option needs an argument 1.541 + eval "opt_MODE=\$opt_MODE_${opt_OPT}" 1.542 + if [ ".$opt_ARG" = . ] && [ ".$opt_ARG_OK" != .yes ]; then 1.543 + if [ ".$opt_MODE" = ".:" ] || [ ".$opt_MODE" = ".+" ]; then 1.544 + opt_PREV="$opt_OPT" 1.545 + continue 1.546 + fi 1.547 + fi 1.548 + 1.549 + # process option 1.550 + case $opt_MODE in 1.551 + '.' ) 1.552 + # boolean option 1.553 + eval "opt_${opt_OPT}=yes" 1.554 + ;; 1.555 + ':' ) 1.556 + # option with argument (multiple occurances override) 1.557 + eval "opt_${opt_OPT}=\"\$opt_ARG\"" 1.558 + ;; 1.559 + '+' ) 1.560 + # option with argument (multiple occurances append) 1.561 + eval "opt_${opt_OPT}=\"\$opt_${opt_OPT}\${ASC_NL}\$opt_ARG\"" 1.562 + ;; 1.563 + * ) 1.564 + echo "$msgprefix:Error: unknown option: \`$opt_OPT'" 1>&2 1.565 + echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2 1.566 + exit 1 1.567 + ;; 1.568 + esac 1.569 +done 1.570 +if [ ".$opt_PREV" != . ]; then 1.571 + echo "$msgprefix:Error: missing argument to option \`$opt_PREV'" 1>&2 1.572 + echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2 1.573 + exit 1 1.574 +fi 1.575 + 1.576 +# process help option 1.577 +if [ ".$opt_h" = .yes ]; then 1.578 + echo "Usage: $toolcmdhelp $str_usage" 1.579 + exit 0 1.580 +fi 1.581 + 1.582 +# complain about incorrect number of arguments 1.583 +case $arg_MODE in 1.584 + '=' ) 1.585 + if [ $# -ne $arg_NUMS ]; then 1.586 + echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2 1.587 + echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2 1.588 + exit 1 1.589 + fi 1.590 + ;; 1.591 + '+' ) 1.592 + if [ $# -lt $arg_NUMS ]; then 1.593 + echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2 1.594 + echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2 1.595 + exit 1 1.596 + fi 1.597 + ;; 1.598 +esac 1.599 + 1.600 +# establish a temporary file on request 1.601 +if [ ".$gen_tmpfile" = .yes ]; then 1.602 + # create (explicitly) secure temporary directory 1.603 + if [ ".$TMPDIR" != . ]; then 1.604 + tmpdir="$TMPDIR" 1.605 + elif [ ".$TEMPDIR" != . ]; then 1.606 + tmpdir="$TEMPDIR" 1.607 + else 1.608 + tmpdir="/tmp" 1.609 + fi 1.610 + tmpdir="$tmpdir/.shtool.$$" 1.611 + ( umask 077 1.612 + rm -rf "$tmpdir" >/dev/null 2>&1 || true 1.613 + mkdir "$tmpdir" >/dev/null 2>&1 1.614 + if [ $? -ne 0 ]; then 1.615 + echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2 1.616 + exit 1 1.617 + fi 1.618 + ) 1.619 + 1.620 + # create (implicitly) secure temporary file 1.621 + tmpfile="$tmpdir/shtool.tmp" 1.622 + touch "$tmpfile" 1.623 +fi 1.624 + 1.625 +# utility function: map string to lower case 1.626 +util_lower () { 1.627 + echo "$1" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' 1.628 +} 1.629 + 1.630 +# utility function: map string to upper case 1.631 +util_upper () { 1.632 + echo "$1" | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 1.633 +} 1.634 + 1.635 +# cleanup procedure 1.636 +shtool_exit () { 1.637 + rc="$1" 1.638 + if [ ".$gen_tmpfile" = .yes ]; then 1.639 + rm -rf "$tmpdir" >/dev/null 2>&1 || true 1.640 + fi 1.641 + exit $rc 1.642 +} 1.643 + 1.644 +## 1.645 +## DISPATCH INTO SCRIPT BODY 1.646 +## 1.647 + 1.648 +case $tool in 1.649 + 1.650 +echo ) 1.651 + ## 1.652 + ## echo -- Print string with optional construct expansion 1.653 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.654 + ## 1.655 + 1.656 + text="$*" 1.657 + 1.658 + # check for broken escape sequence expansion 1.659 + seo='' 1.660 + bytes=`echo '\1' | wc -c | awk '{ printf("%s", $1); }'` 1.661 + if [ ".$bytes" != .3 ]; then 1.662 + bytes=`echo -E '\1' | wc -c | awk '{ printf("%s", $1); }'` 1.663 + if [ ".$bytes" = .3 ]; then 1.664 + seo='-E' 1.665 + fi 1.666 + fi 1.667 + 1.668 + # check for existing -n option (to suppress newline) 1.669 + minusn='' 1.670 + bytes=`echo -n 123 2>/dev/null | wc -c | awk '{ printf("%s", $1); }'` 1.671 + if [ ".$bytes" = .3 ]; then 1.672 + minusn='-n' 1.673 + fi 1.674 + 1.675 + # determine terminal bold sequence 1.676 + term_bold='' 1.677 + term_norm='' 1.678 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[Bb]'`" != . ]; then 1.679 + case $TERM in 1.680 + # for the most important terminal types we directly know the sequences 1.681 + xterm|xterm*|vt220|vt220*) 1.682 + term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null` 1.683 + term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null` 1.684 + ;; 1.685 + vt100|vt100*|cygwin) 1.686 + term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null` 1.687 + term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null` 1.688 + ;; 1.689 + # for all others, we try to use a possibly existing `tput' or `tcout' utility 1.690 + * ) 1.691 + paths=`echo $PATH | sed -e 's/:/ /g'` 1.692 + for tool in tput tcout; do 1.693 + for dir in $paths; do 1.694 + if [ -r "$dir/$tool" ]; then 1.695 + for seq in bold md smso; do # 'smso' is last 1.696 + bold="`$dir/$tool $seq 2>/dev/null`" 1.697 + if [ ".$bold" != . ]; then 1.698 + term_bold="$bold" 1.699 + break 1.700 + fi 1.701 + done 1.702 + if [ ".$term_bold" != . ]; then 1.703 + for seq in sgr0 me rmso init reset; do # 'reset' is last 1.704 + norm="`$dir/$tool $seq 2>/dev/null`" 1.705 + if [ ".$norm" != . ]; then 1.706 + term_norm="$norm" 1.707 + break 1.708 + fi 1.709 + done 1.710 + fi 1.711 + break 1.712 + fi 1.713 + done 1.714 + if [ ".$term_bold" != . ] && [ ".$term_norm" != . ]; then 1.715 + break; 1.716 + fi 1.717 + done 1.718 + ;; 1.719 + esac 1.720 + if [ ".$term_bold" = . ] || [ ".$term_norm" = . ]; then 1.721 + echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2 1.722 + term_bold='' 1.723 + term_norm='' 1.724 + fi 1.725 + fi 1.726 + 1.727 + # determine user name 1.728 + username='' 1.729 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[uUgG]'`" != . ]; then 1.730 + username="`(id -un) 2>/dev/null`" 1.731 + if [ ".$username" = . ]; then 1.732 + str="`(id) 2>/dev/null`" 1.733 + if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then 1.734 + username=`echo $str | sed -e 's/^uid[ ]*=[ ]*[0-9]*(//' -e 's/).*$//'` 1.735 + fi 1.736 + if [ ".$username" = . ]; then 1.737 + username="$LOGNAME" 1.738 + if [ ".$username" = . ]; then 1.739 + username="$USER" 1.740 + if [ ".$username" = . ]; then 1.741 + username="`(whoami) 2>/dev/null |\ 1.742 + awk '{ printf("%s", $1); }'`" 1.743 + if [ ".$username" = . ]; then 1.744 + username="`(who am i) 2>/dev/null |\ 1.745 + awk '{ printf("%s", $1); }'`" 1.746 + if [ ".$username" = . ]; then 1.747 + username='unknown' 1.748 + fi 1.749 + fi 1.750 + fi 1.751 + fi 1.752 + fi 1.753 + fi 1.754 + fi 1.755 + 1.756 + # determine user id 1.757 + userid='' 1.758 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%U'`" != . ]; then 1.759 + userid="`(id -u) 2>/dev/null`" 1.760 + if [ ".$userid" = . ]; then 1.761 + userid="`(id -u ${username}) 2>/dev/null`" 1.762 + if [ ".$userid" = . ]; then 1.763 + str="`(id) 2>/dev/null`" 1.764 + if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then 1.765 + userid=`echo $str | sed -e 's/^uid[ ]*=[ ]*//' -e 's/(.*$//'` 1.766 + fi 1.767 + if [ ".$userid" = . ]; then 1.768 + userid=`(getent passwd ${username}) 2>/dev/null | \ 1.769 + sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'` 1.770 + if [ ".$userid" = . ]; then 1.771 + userid=`grep "^${username}:" /etc/passwd 2>/dev/null | \ 1.772 + sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'` 1.773 + if [ ".$userid" = . ]; then 1.774 + userid=`(ypmatch "${username}" passwd; nismatch "${username}" passwd) 2>/dev/null | \ 1.775 + sed -e 'q' | sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'` 1.776 + if [ ".$userid" = . ]; then 1.777 + userid=`(nidump passwd . | grep "^${username}:") 2>/dev/null | \ 1.778 + sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'` 1.779 + if [ ".$userid" = . ]; then 1.780 + userid='?' 1.781 + fi 1.782 + fi 1.783 + fi 1.784 + fi 1.785 + fi 1.786 + fi 1.787 + fi 1.788 + fi 1.789 + 1.790 + # determine (primary) group id 1.791 + groupid='' 1.792 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[gG]'`" != . ]; then 1.793 + groupid="`(id -g ${username}) 2>/dev/null`" 1.794 + if [ ".$groupid" = . ]; then 1.795 + str="`(id) 2>/dev/null`" 1.796 + if [ ".`echo $str | grep 'gid[ ]*=[ ]*[0-9]*('`" != . ]; then 1.797 + groupid=`echo $str | sed -e 's/^.*gid[ ]*=[ ]*//' -e 's/(.*$//'` 1.798 + fi 1.799 + if [ ".$groupid" = . ]; then 1.800 + groupid=`(getent passwd ${username}) 2>/dev/null | \ 1.801 + sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'` 1.802 + if [ ".$groupid" = . ]; then 1.803 + groupid=`grep "^${username}:" /etc/passwd 2>/dev/null | \ 1.804 + sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'` 1.805 + if [ ".$groupid" = . ]; then 1.806 + groupid=`(ypmatch "${username}" passwd; nismatch "${username}" passwd) 2>/dev/null | \ 1.807 + sed -e 'q' | sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'` 1.808 + if [ ".$groupid" = . ]; then 1.809 + groupid=`(nidump passwd . | grep "^${username}:") 2>/dev/null | \ 1.810 + sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'` 1.811 + if [ ".$groupid" = . ]; then 1.812 + groupid='?' 1.813 + fi 1.814 + fi 1.815 + fi 1.816 + fi 1.817 + fi 1.818 + fi 1.819 + fi 1.820 + 1.821 + # determine (primary) group name 1.822 + groupname='' 1.823 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%g'`" != . ]; then 1.824 + groupname="`(id -gn ${username}) 2>/dev/null`" 1.825 + if [ ".$groupname" = . ]; then 1.826 + str="`(id) 2>/dev/null`" 1.827 + if [ ".`echo $str | grep 'gid[ ]*=[ ]*[0-9]*('`" != . ]; then 1.828 + groupname=`echo $str | sed -e 's/^.*gid[ ]*=[ ]*[0-9]*(//' -e 's/).*$//'` 1.829 + fi 1.830 + if [ ".$groupname" = . ]; then 1.831 + groupname=`(getent group) 2>/dev/null | \ 1.832 + grep "^[^:]*:[^:]*:${groupid}:" | \ 1.833 + sed -e 's/:.*$//'` 1.834 + if [ ".$groupname" = . ]; then 1.835 + groupname=`grep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \ 1.836 + sed -e 's/:.*$//'` 1.837 + if [ ".$groupname" = . ]; then 1.838 + groupname=`(ypcat group; niscat group) 2>/dev/null | \ 1.839 + sed -e 'q' | grep "^[^:]*:[^:]*:${groupid}:" | \ 1.840 + sed -e 's/:.*$//'` 1.841 + if [ ".$groupname" = . ]; then 1.842 + groupname=`(nidump group .) 2>/dev/null | \ 1.843 + grep "^[^:]*:[^:]*:${groupid}:" | \ 1.844 + sed -e 's/:.*$//'` 1.845 + if [ ".$groupname" = . ]; then 1.846 + groupname='?' 1.847 + fi 1.848 + fi 1.849 + fi 1.850 + fi 1.851 + fi 1.852 + fi 1.853 + fi 1.854 + 1.855 + # determine host and domain name 1.856 + hostname='' 1.857 + domainname='' 1.858 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%h'`" != . ]; then 1.859 + hostname="`(uname -n) 2>/dev/null |\ 1.860 + awk '{ printf("%s", $1); }'`" 1.861 + if [ ".$hostname" = . ]; then 1.862 + hostname="`(hostname) 2>/dev/null |\ 1.863 + awk '{ printf("%s", $1); }'`" 1.864 + if [ ".$hostname" = . ]; then 1.865 + hostname='unknown' 1.866 + fi 1.867 + fi 1.868 + case $hostname in 1.869 + *.* ) 1.870 + domainname=".`echo $hostname | cut -d. -f2-`" 1.871 + hostname="`echo $hostname | cut -d. -f1`" 1.872 + ;; 1.873 + esac 1.874 + fi 1.875 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%d'`" != . ]; then 1.876 + if [ ".$domainname" = . ]; then 1.877 + if [ -f /etc/resolv.conf ]; then 1.878 + domainname="`grep '^[ ]*domain' /etc/resolv.conf | sed -e 'q' |\ 1.879 + sed -e 's/.*domain//' \ 1.880 + -e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \ 1.881 + -e 's/^\.//' -e 's/^/./' |\ 1.882 + awk '{ printf("%s", $1); }'`" 1.883 + if [ ".$domainname" = . ]; then 1.884 + domainname="`grep '^[ ]*search' /etc/resolv.conf | sed -e 'q' |\ 1.885 + sed -e 's/.*search//' \ 1.886 + -e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \ 1.887 + -e 's/ .*//' -e 's/ .*//' \ 1.888 + -e 's/^\.//' -e 's/^/./' |\ 1.889 + awk '{ printf("%s", $1); }'`" 1.890 + fi 1.891 + fi 1.892 + fi 1.893 + fi 1.894 + 1.895 + # determine current time 1.896 + time_day='' 1.897 + time_month='' 1.898 + time_year='' 1.899 + time_monthname='' 1.900 + if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[DMYm]'`" != . ]; then 1.901 + time_day=`date '+%d'` 1.902 + time_month=`date '+%m'` 1.903 + time_year=`date '+%Y' 2>/dev/null` 1.904 + if [ ".$time_year" = . ]; then 1.905 + time_year=`date '+%y'` 1.906 + case $time_year in 1.907 + [5-9][0-9]) time_year="19$time_year" ;; 1.908 + [0-4][0-9]) time_year="20$time_year" ;; 1.909 + esac 1.910 + fi 1.911 + case $time_month in 1.912 + 1|01) time_monthname='Jan' ;; 1.913 + 2|02) time_monthname='Feb' ;; 1.914 + 3|03) time_monthname='Mar' ;; 1.915 + 4|04) time_monthname='Apr' ;; 1.916 + 5|05) time_monthname='May' ;; 1.917 + 6|06) time_monthname='Jun' ;; 1.918 + 7|07) time_monthname='Jul' ;; 1.919 + 8|08) time_monthname='Aug' ;; 1.920 + 9|09) time_monthname='Sep' ;; 1.921 + 10) time_monthname='Oct' ;; 1.922 + 11) time_monthname='Nov' ;; 1.923 + 12) time_monthname='Dec' ;; 1.924 + esac 1.925 + fi 1.926 + 1.927 + # expand special ``%x'' constructs 1.928 + if [ ".$opt_e" = .yes ]; then 1.929 + text=`echo $seo "$text" |\ 1.930 + sed -e "s/%B/${term_bold}/g" \ 1.931 + -e "s/%b/${term_norm}/g" \ 1.932 + -e "s/%u/${username}/g" \ 1.933 + -e "s/%U/${userid}/g" \ 1.934 + -e "s/%g/${groupname}/g" \ 1.935 + -e "s/%G/${groupid}/g" \ 1.936 + -e "s/%h/${hostname}/g" \ 1.937 + -e "s/%d/${domainname}/g" \ 1.938 + -e "s/%D/${time_day}/g" \ 1.939 + -e "s/%M/${time_month}/g" \ 1.940 + -e "s/%Y/${time_year}/g" \ 1.941 + -e "s/%m/${time_monthname}/g" 2>/dev/null` 1.942 + fi 1.943 + 1.944 + # create output 1.945 + if [ .$opt_n = .no ]; then 1.946 + echo $seo "$text" 1.947 + else 1.948 + # the harder part: echo -n is best, because 1.949 + # awk may complain about some \xx sequences. 1.950 + if [ ".$minusn" != . ]; then 1.951 + echo $seo $minusn "$text" 1.952 + else 1.953 + echo dummy | awk '{ printf("%s", TEXT); }' TEXT="$text" 1.954 + fi 1.955 + fi 1.956 + 1.957 + shtool_exit 0 1.958 + ;; 1.959 + 1.960 +mdate ) 1.961 + ## 1.962 + ## mdate -- Pretty-print modification time of a file or dir 1.963 + ## Copyright (c) 1995-1997 Free Software Foundation, Inc. 1.964 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.965 + ## 1.966 + 1.967 + fod="$1" 1.968 + case "$opt_o" in 1.969 + [dmy][dmy][dmy] ) 1.970 + ;; 1.971 + * ) echo "$msgprefix:Error: invalid argument to option \`-o': $opt_o" 1>&2 1.972 + shtool_exit 1 1.973 + ;; 1.974 + esac 1.975 + if [ ! -r "$fod" ]; then 1.976 + echo "$msgprefix:Error: file or directory not found: $fod" 1>&2 1.977 + shtool_exit 1 1.978 + fi 1.979 + 1.980 + # GNU ls changes its time format in response to the TIME_STYLE 1.981 + # variable. Since we cannot assume "unset" works, revert this 1.982 + # variable to its documented default. 1.983 + if [ ".$TIME_STYLE" != . ]; then 1.984 + TIME_STYLE=posix-long-iso 1.985 + export TIME_STYLE 1.986 + fi 1.987 + 1.988 + # get the extended ls output of the file or directory. 1.989 + if /bin/ls -L /dev/null >/dev/null 2>&1; then 1.990 + set - x`/bin/ls -L -l -d $fod` 1.991 + else 1.992 + set - x`/bin/ls -l -d $fod` 1.993 + fi 1.994 + 1.995 + # The month is at least the fourth argument 1.996 + # (3 shifts here, the next inside the loop). 1.997 + shift; shift; shift 1.998 + 1.999 + # Find the month. Next argument is day, followed by the year or time. 1.1000 + month="" 1.1001 + while [ ".$month" = . ]; do 1.1002 + shift 1.1003 + case $1 in 1.1004 + Jan) month=January; nummonth=1 ;; 1.1005 + Feb) month=February; nummonth=2 ;; 1.1006 + Mar) month=March; nummonth=3 ;; 1.1007 + Apr) month=April; nummonth=4 ;; 1.1008 + May) month=May; nummonth=5 ;; 1.1009 + Jun) month=June; nummonth=6 ;; 1.1010 + Jul) month=July; nummonth=7 ;; 1.1011 + Aug) month=August; nummonth=8 ;; 1.1012 + Sep) month=September; nummonth=9 ;; 1.1013 + Oct) month=October; nummonth=10 ;; 1.1014 + Nov) month=November; nummonth=11 ;; 1.1015 + Dec) month=December; nummonth=12 ;; 1.1016 + esac 1.1017 + done 1.1018 + day="$2" 1.1019 + year="$3" 1.1020 + 1.1021 + # We finally have to deal with the problem that the "ls" output 1.1022 + # gives either the time of the day or the year. 1.1023 + case $year in 1.1024 + *:*) 1.1025 + this_year=`date '+%Y' 2>/dev/null` 1.1026 + if [ ".$this_year" = . ]; then 1.1027 + this_year=`date '+%y'` 1.1028 + case $this_year in 1.1029 + [5-9][0-9]) this_year="19$this_year" ;; 1.1030 + [0-4][0-9]) this_year="20$this_year" ;; 1.1031 + esac 1.1032 + fi 1.1033 + # for the following months of the last year the time notation 1.1034 + # is usually also used for files modified in the last year. 1.1035 + this_month=`date '+%m'` 1.1036 + if (expr $nummonth \> $this_month) >/dev/null; then 1.1037 + this_year=`expr $this_year - 1` 1.1038 + fi 1.1039 + year="$this_year" 1.1040 + ;; 1.1041 + esac 1.1042 + 1.1043 + # Optionally fill day and month with leeding zeros 1.1044 + if [ ".$opt_z" = .yes ]; then 1.1045 + case $day in 1.1046 + [0-9][0-9] ) ;; 1.1047 + [0-9] ) day="0$day" ;; 1.1048 + esac 1.1049 + case $nummonth in 1.1050 + [0-9][0-9] ) ;; 1.1051 + [0-9] ) nummonth="0$nummonth" ;; 1.1052 + esac 1.1053 + fi 1.1054 + 1.1055 + # Optionally use digits for month 1.1056 + if [ ".$opt_d" = .yes ]; then 1.1057 + month="$nummonth" 1.1058 + fi 1.1059 + 1.1060 + # Optionally shorten the month name to three characters 1.1061 + if [ ".$opt_s" = .yes ]; then 1.1062 + month=`echo $month | cut -c1-3` 1.1063 + fi 1.1064 + 1.1065 + # Output the resulting date string 1.1066 + echo dummy | awk '{ 1.1067 + for (i = 0; i < 3; i++) { 1.1068 + now = substr(order, 1, 1); 1.1069 + order = substr(order, 2); 1.1070 + if (now == "d") 1.1071 + out = day; 1.1072 + else if (now == "m") 1.1073 + out = month; 1.1074 + else if (now == "y") 1.1075 + out = year; 1.1076 + if (i < 2) 1.1077 + printf("%s%s", out, field); 1.1078 + else 1.1079 + printf("%s", out); 1.1080 + } 1.1081 + if (newline != "yes") 1.1082 + printf("\n"); 1.1083 + }' "day=$day" "month=$month" "year=$year" \ 1.1084 + "field=$opt_f" "order=$opt_o" "newline=$opt_n" 1.1085 + 1.1086 + shtool_exit 0 1.1087 + ;; 1.1088 + 1.1089 +table ) 1.1090 + ## 1.1091 + ## table -- Pretty-print a field-separated list as a table 1.1092 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1093 + ## 1.1094 + 1.1095 + if [ $opt_c -gt 4 ]; then 1.1096 + echo "$msgprefix:Error: Invalid number of colums (1..4 allowed only)" 1>&2 1.1097 + shtool_exit 1 1.1098 + fi 1.1099 + case "x$opt_F" in 1.1100 + x? ) ;; 1.1101 + * ) echo "$msgprefix:Error: Invalid separator (one char allowed only)" 1>&2; shtool_exit 1 ;; 1.1102 + esac 1.1103 + 1.1104 + # split the list into a table 1.1105 + list=` 1.1106 + IFS="$opt_F" 1.1107 + for entry in $*; do 1.1108 + if [ ".$entry" != . ]; then 1.1109 + echo "$entry" 1.1110 + fi 1.1111 + done |\ 1.1112 + awk " 1.1113 + BEGIN { list = \"\"; n = 0; } 1.1114 + { 1.1115 + list = list \\$1; 1.1116 + n = n + 1; 1.1117 + if (n < $opt_c) { 1.1118 + list = list \":\"; 1.1119 + } 1.1120 + if (n == $opt_c) { 1.1121 + list = list \"\\n\"; 1.1122 + n = 0; 1.1123 + } 1.1124 + } 1.1125 + END { print list; } 1.1126 + " 1.1127 + ` 1.1128 + 1.1129 + # format table cells and make sure table 1.1130 + # doesn't exceed maximum width 1.1131 + OIFS="$IFS" 1.1132 + IFS=' 1.1133 +' 1.1134 + for entry in $list; do 1.1135 + case $opt_c in 1.1136 + 1 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s\\n\", \$1); }'" ;; 1.1137 + 2 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s %-${opt_w}s\\n\", \$1, \$2); }'" ;; 1.1138 + 3 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s %-${opt_w}s %-${opt_w}s\\n\", \$1, \$2, \$3); }'" ;; 1.1139 + 4 ) eval "echo \"\${entry}\" | awk -F: '{ printf(\"%-${opt_w}s %-${opt_w}s %-${opt_w}s %-${opt_w}s\\n\", \$1, \$2, \$3, \$4); }'" ;; 1.1140 + esac 1.1141 + done |\ 1.1142 + awk "{ 1.1143 + if (length(\$0) > $opt_s) { 1.1144 + printf(\"%s\\n\", substr(\$0, 0, $opt_s-1)); 1.1145 + } else { 1.1146 + print \$0; 1.1147 + } 1.1148 + }" 1.1149 + IFS="$OIFS" 1.1150 + 1.1151 + shtool_exit 0 1.1152 + ;; 1.1153 + 1.1154 +prop ) 1.1155 + ## 1.1156 + ## prop -- Display progress with a running propeller 1.1157 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1158 + ## 1.1159 + 1.1160 + perl='' 1.1161 + for dir in `echo $PATH | sed -e 's/:/ /g'` .; do 1.1162 + if [ -f "$dir/perl" ]; then 1.1163 + perl="$dir/perl" 1.1164 + break 1.1165 + fi 1.1166 + done 1.1167 + if [ ".$perl" != . ]; then 1.1168 + # Perl is preferred because writing to STDERR in 1.1169 + # Perl really writes immediately as one would expect 1.1170 + $perl -e ' 1.1171 + @p = ("|","/","-","\\"); 1.1172 + $i = 0; 1.1173 + while (<STDIN>) { 1.1174 + printf(STDERR "\r%s...%s\b", $ARGV[0], $p[$i++]); 1.1175 + $i = 0 if ($i > 3); 1.1176 + } 1.1177 + printf(STDERR "\r%s \n", $ARGV[0]); 1.1178 + ' "$opt_p" 1.1179 + else 1.1180 + # But if Perl doesn't exists we use Awk even 1.1181 + # some Awk's buffer even the /dev/stderr writing :-( 1.1182 + awk ' 1.1183 + BEGIN { 1.1184 + split("|#/#-#\\", p, "#"); 1.1185 + i = 1; 1.1186 + } 1.1187 + { 1.1188 + printf("\r%s%c\b", prefix, p[i++]) > "/dev/stderr"; 1.1189 + if (i > 4) { i = 1; } 1.1190 + } 1.1191 + END { 1.1192 + printf("\r%s \n", prefix) > "/dev/stderr"; 1.1193 + } 1.1194 + ' "prefix=$opt_p" 1.1195 + fi 1.1196 + 1.1197 + shtool_exit 0 1.1198 + ;; 1.1199 + 1.1200 +move ) 1.1201 + ## 1.1202 + ## move -- Move files with simultaneous substitution 1.1203 + ## Copyright (c) 1999-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1204 + ## 1.1205 + 1.1206 + src="$1" 1.1207 + dst="$2" 1.1208 + 1.1209 + # consistency checks 1.1210 + if [ ".$src" = . ] || [ ".$dst" = . ]; then 1.1211 + echo "$msgprefix:Error: Invalid arguments" 1>&2 1.1212 + shtool_exit 1 1.1213 + fi 1.1214 + if [ ".$src" = ".$dst" ]; then 1.1215 + echo "$msgprefix:Error: Source and destination files are the same" 1>&2 1.1216 + shtool_exit 1 1.1217 + fi 1.1218 + expsrc="$src" 1.1219 + if [ ".$opt_e" = .yes ]; then 1.1220 + expsrc="`echo $expsrc`" 1.1221 + fi 1.1222 + if [ ".$opt_e" = .yes ]; then 1.1223 + if [ ".`echo "$src" | sed -e 's;^.*\\*.*$;;'`" = ".$src" ]; then 1.1224 + echo "$msgprefix:Error: Source doesn't contain wildcard ('*'): $dst" 1>&2 1.1225 + shtool_exit 1 1.1226 + fi 1.1227 + if [ ".`echo "$dst" | sed -e 's;^.*%[1-9].*$;;'`" = ".$dst" ]; then 1.1228 + echo "$msgprefix:Error: Destination doesn't contain substitution ('%N'): $dst" 1>&2 1.1229 + shtool_exit 1 1.1230 + fi 1.1231 + if [ ".$expsrc" = ".$src" ]; then 1.1232 + echo "$msgprefix:Error: Sources not found or no asterisk : $src" 1>&2 1.1233 + shtool_exit 1 1.1234 + fi 1.1235 + else 1.1236 + if [ ! -r "$src" ]; then 1.1237 + echo "$msgprefix:Error: Source not found: $src" 1>&2 1.1238 + shtool_exit 1 1.1239 + fi 1.1240 + fi 1.1241 + 1.1242 + # determine substitution patterns 1.1243 + if [ ".$opt_e" = .yes ]; then 1.1244 + srcpat=`echo "$src" | sed -e 's/\\./\\\\./g' -e 's/;/\\;/g' -e 's;\\*;\\\\(.*\\\\);g'` 1.1245 + dstpat=`echo "$dst" | sed -e 's;%\([1-9]\);\\\\\1;g'` 1.1246 + fi 1.1247 + 1.1248 + # iterate over source(s) 1.1249 + for onesrc in $expsrc; do 1.1250 + if [ .$opt_e = .yes ]; then 1.1251 + onedst=`echo $onesrc | sed -e "s;$srcpat;$dstpat;"` 1.1252 + else 1.1253 + onedst="$dst" 1.1254 + fi 1.1255 + errorstatus=0 1.1256 + if [ ".$opt_v" = .yes ]; then 1.1257 + echo "$onesrc -> $onedst" 1.1258 + fi 1.1259 + if [ ".$opt_p" = .yes ]; then 1.1260 + if [ -r $onedst ]; then 1.1261 + if cmp -s $onesrc $onedst; then 1.1262 + if [ ".$opt_t" = .yes ]; then 1.1263 + echo "rm -f $onesrc" 1>&2 1.1264 + fi 1.1265 + rm -f $onesrc || errorstatus=$? 1.1266 + else 1.1267 + if [ ".$opt_t" = .yes ]; then 1.1268 + echo "mv -f $onesrc $onedst" 1>&2 1.1269 + fi 1.1270 + mv -f $onesrc $onedst || errorstatus=$? 1.1271 + fi 1.1272 + else 1.1273 + if [ ".$opt_t" = .yes ]; then 1.1274 + echo "mv -f $onesrc $onedst" 1>&2 1.1275 + fi 1.1276 + mv -f $onesrc $onedst || errorstatus=$? 1.1277 + fi 1.1278 + else 1.1279 + if [ ".$opt_t" = .yes ]; then 1.1280 + echo "mv -f $onesrc $onedst" 1>&2 1.1281 + fi 1.1282 + mv -f $onesrc $onedst || errorstatus=$? 1.1283 + fi 1.1284 + if [ $errorstatus -ne 0 ]; then 1.1285 + break; 1.1286 + fi 1.1287 + done 1.1288 + 1.1289 + shtool_exit $errorstatus 1.1290 + ;; 1.1291 + 1.1292 +install ) 1.1293 + ## 1.1294 + ## install -- Install a program, script or datafile 1.1295 + ## Copyright (c) 1997-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1296 + ## 1.1297 + 1.1298 + # special case: "shtool install -d <dir> [...]" internally 1.1299 + # maps to "shtool mkdir -f -p -m 755 <dir> [...]" 1.1300 + if [ "$opt_d" = yes ]; then 1.1301 + cmd="$0 mkdir -f -p -m 755" 1.1302 + if [ ".$opt_o" != . ]; then 1.1303 + cmd="$cmd -o '$opt_o'" 1.1304 + fi 1.1305 + if [ ".$opt_g" != . ]; then 1.1306 + cmd="$cmd -g '$opt_g'" 1.1307 + fi 1.1308 + if [ ".$opt_v" = .yes ]; then 1.1309 + cmd="$cmd -v" 1.1310 + fi 1.1311 + if [ ".$opt_t" = .yes ]; then 1.1312 + cmd="$cmd -t" 1.1313 + fi 1.1314 + for dir in "$@"; do 1.1315 + eval "$cmd $dir" || shtool_exit $? 1.1316 + done 1.1317 + shtool_exit 0 1.1318 + fi 1.1319 + 1.1320 + # determine source(s) and destination 1.1321 + argc=$# 1.1322 + srcs="" 1.1323 + while [ $# -gt 1 ]; do 1.1324 + srcs="$srcs $1" 1.1325 + shift 1.1326 + done 1.1327 + dstpath="$1" 1.1328 + 1.1329 + # type check for destination 1.1330 + dstisdir=0 1.1331 + if [ -d $dstpath ]; then 1.1332 + dstpath=`echo "$dstpath" | sed -e 's:/$::'` 1.1333 + dstisdir=1 1.1334 + fi 1.1335 + 1.1336 + # consistency check for destination 1.1337 + if [ $argc -gt 2 ] && [ $dstisdir = 0 ]; then 1.1338 + echo "$msgprefix:Error: multiple sources require destination to be directory" 1>&2 1.1339 + shtool_exit 1 1.1340 + fi 1.1341 + 1.1342 + # iterate over all source(s) 1.1343 + for src in $srcs; do 1.1344 + dst=$dstpath 1.1345 + 1.1346 + # if destination is a directory, append the input filename 1.1347 + if [ $dstisdir = 1 ]; then 1.1348 + dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'` 1.1349 + dst="$dst/$dstfile" 1.1350 + fi 1.1351 + 1.1352 + # check for correct arguments 1.1353 + if [ ".$src" = ".$dst" ]; then 1.1354 + echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2 1.1355 + continue 1.1356 + fi 1.1357 + if [ -d "$src" ]; then 1.1358 + echo "$msgprefix:Warning: source \`$src' is a directory - skipped" 1>&2 1.1359 + continue 1.1360 + fi 1.1361 + 1.1362 + # make a temp file name in the destination directory 1.1363 + dsttmp=`echo $dst |\ 1.1364 + sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \ 1.1365 + -e "s;\$;/#INST@$$#;"` 1.1366 + 1.1367 + # verbosity 1.1368 + if [ ".$opt_v" = .yes ]; then 1.1369 + echo "$src -> $dst" 1>&2 1.1370 + fi 1.1371 + 1.1372 + # copy or move the file name to the temp name 1.1373 + # (because we might be not allowed to change the source) 1.1374 + if [ ".$opt_C" = .yes ]; then 1.1375 + opt_c=yes 1.1376 + fi 1.1377 + if [ ".$opt_c" = .yes ]; then 1.1378 + if [ ".$opt_t" = .yes ]; then 1.1379 + echo "cp $src $dsttmp" 1>&2 1.1380 + fi 1.1381 + cp "$src" "$dsttmp" || shtool_exit $? 1.1382 + else 1.1383 + if [ ".$opt_t" = .yes ]; then 1.1384 + echo "mv $src $dsttmp" 1>&2 1.1385 + fi 1.1386 + mv "$src" "$dsttmp" || shtool_exit $? 1.1387 + fi 1.1388 + 1.1389 + # adjust the target file 1.1390 + if [ ".$opt_e" != . ]; then 1.1391 + sed='sed' 1.1392 + OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS" 1.1393 + for e 1.1394 + do 1.1395 + sed="$sed -e '$e'" 1.1396 + done 1.1397 + cp "$dsttmp" "$dsttmp.old" 1.1398 + chmod u+w $dsttmp 1.1399 + eval "$sed <$dsttmp.old >$dsttmp" || shtool_exit $? 1.1400 + rm -f $dsttmp.old 1.1401 + fi 1.1402 + if [ ".$opt_s" = .yes ]; then 1.1403 + if [ ".$opt_t" = .yes ]; then 1.1404 + echo "strip $dsttmp" 1>&2 1.1405 + fi 1.1406 + strip $dsttmp || shtool_exit $? 1.1407 + fi 1.1408 + if [ ".$opt_o" != . ]; then 1.1409 + if [ ".$opt_t" = .yes ]; then 1.1410 + echo "chown $opt_o $dsttmp" 1>&2 1.1411 + fi 1.1412 + chown $opt_o $dsttmp || shtool_exit $? 1.1413 + fi 1.1414 + if [ ".$opt_g" != . ]; then 1.1415 + if [ ".$opt_t" = .yes ]; then 1.1416 + echo "chgrp $opt_g $dsttmp" 1>&2 1.1417 + fi 1.1418 + chgrp $opt_g $dsttmp || shtool_exit $? 1.1419 + fi 1.1420 + if [ ".$opt_m" != ".-" ]; then 1.1421 + if [ ".$opt_t" = .yes ]; then 1.1422 + echo "chmod $opt_m $dsttmp" 1>&2 1.1423 + fi 1.1424 + chmod $opt_m $dsttmp || shtool_exit $? 1.1425 + fi 1.1426 + 1.1427 + # determine whether to do a quick install 1.1428 + # (has to be done _after_ the strip was already done) 1.1429 + quick=no 1.1430 + if [ ".$opt_C" = .yes ]; then 1.1431 + if [ -r $dst ]; then 1.1432 + if cmp -s "$src" "$dst"; then 1.1433 + quick=yes 1.1434 + fi 1.1435 + fi 1.1436 + fi 1.1437 + 1.1438 + # finally, install the file to the real destination 1.1439 + if [ $quick = yes ]; then 1.1440 + if [ ".$opt_t" = .yes ]; then 1.1441 + echo "rm -f $dsttmp" 1>&2 1.1442 + fi 1.1443 + rm -f $dsttmp 1.1444 + else 1.1445 + if [ ".$opt_t" = .yes ]; then 1.1446 + echo "rm -f $dst && mv $dsttmp $dst" 1>&2 1.1447 + fi 1.1448 + rm -f $dst && mv $dsttmp $dst 1.1449 + fi 1.1450 + done 1.1451 + 1.1452 + shtool_exit 0 1.1453 + ;; 1.1454 + 1.1455 +mkdir ) 1.1456 + ## 1.1457 + ## mkdir -- Make one or more directories 1.1458 + ## Copyright (c) 1996-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1459 + ## 1.1460 + 1.1461 + errstatus=0 1.1462 + for p in ${1+"$@"}; do 1.1463 + # if the directory already exists... 1.1464 + if [ -d "$p" ]; then 1.1465 + if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then 1.1466 + echo "$msgprefix:Error: directory already exists: $p" 1>&2 1.1467 + errstatus=1 1.1468 + break 1.1469 + else 1.1470 + continue 1.1471 + fi 1.1472 + fi 1.1473 + # if the directory has to be created... 1.1474 + if [ ".$opt_p" = .no ]; then 1.1475 + if [ ".$opt_t" = .yes ]; then 1.1476 + echo "mkdir $p" 1>&2 1.1477 + fi 1.1478 + mkdir $p || errstatus=$? 1.1479 + if [ ".$opt_o" != . ]; then 1.1480 + if [ ".$opt_t" = .yes ]; then 1.1481 + echo "chown $opt_o $p" 1>&2 1.1482 + fi 1.1483 + chown $opt_o $p || errstatus=$? 1.1484 + fi 1.1485 + if [ ".$opt_g" != . ]; then 1.1486 + if [ ".$opt_t" = .yes ]; then 1.1487 + echo "chgrp $opt_g $p" 1>&2 1.1488 + fi 1.1489 + chgrp $opt_g $p || errstatus=$? 1.1490 + fi 1.1491 + if [ ".$opt_m" != . ]; then 1.1492 + if [ ".$opt_t" = .yes ]; then 1.1493 + echo "chmod $opt_m $p" 1>&2 1.1494 + fi 1.1495 + chmod $opt_m $p || errstatus=$? 1.1496 + fi 1.1497 + else 1.1498 + # the smart situation 1.1499 + set fnord `echo ":$p" |\ 1.1500 + sed -e 's/^:\//%/' \ 1.1501 + -e 's/^://' \ 1.1502 + -e 's/\// /g' \ 1.1503 + -e 's/^%/\//'` 1.1504 + shift 1.1505 + pathcomp='' 1.1506 + for d in ${1+"$@"}; do 1.1507 + pathcomp="$pathcomp$d" 1.1508 + case "$pathcomp" in 1.1509 + -* ) pathcomp="./$pathcomp" ;; 1.1510 + esac 1.1511 + if [ ! -d "$pathcomp" ]; then 1.1512 + if [ ".$opt_t" = .yes ]; then 1.1513 + echo "mkdir $pathcomp" 1>&2 1.1514 + fi 1.1515 + mkdir $pathcomp || errstatus=$? 1.1516 + if [ ".$opt_o" != . ]; then 1.1517 + if [ ".$opt_t" = .yes ]; then 1.1518 + echo "chown $opt_o $pathcomp" 1>&2 1.1519 + fi 1.1520 + chown $opt_o $pathcomp || errstatus=$? 1.1521 + fi 1.1522 + if [ ".$opt_g" != . ]; then 1.1523 + if [ ".$opt_t" = .yes ]; then 1.1524 + echo "chgrp $opt_g $pathcomp" 1>&2 1.1525 + fi 1.1526 + chgrp $opt_g $pathcomp || errstatus=$? 1.1527 + fi 1.1528 + if [ ".$opt_m" != . ]; then 1.1529 + if [ ".$opt_t" = .yes ]; then 1.1530 + echo "chmod $opt_m $pathcomp" 1>&2 1.1531 + fi 1.1532 + chmod $opt_m $pathcomp || errstatus=$? 1.1533 + fi 1.1534 + fi 1.1535 + pathcomp="$pathcomp/" 1.1536 + done 1.1537 + fi 1.1538 + done 1.1539 + 1.1540 + shtool_exit $errstatus 1.1541 + ;; 1.1542 + 1.1543 +mkln ) 1.1544 + ## 1.1545 + ## mkln -- Make link with calculation of relative paths 1.1546 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1547 + ## 1.1548 + 1.1549 + # determine source(s) and destination 1.1550 + args=$? 1.1551 + srcs="" 1.1552 + while [ $# -gt 1 ]; do 1.1553 + srcs="$srcs $1" 1.1554 + shift 1.1555 + done 1.1556 + dst="$1" 1.1557 + if [ ! -d $dst ]; then 1.1558 + if [ $args -gt 2 ]; then 1.1559 + echo "$msgprefix:Error: multiple sources not allowed when target isn't a directory" 1>&2 1.1560 + shtool_exit 1 1.1561 + fi 1.1562 + fi 1.1563 + 1.1564 + # determine link options 1.1565 + lnopt="" 1.1566 + if [ ".$opt_f" = .yes ]; then 1.1567 + lnopt="$lnopt -f" 1.1568 + fi 1.1569 + if [ ".$opt_s" = .yes ]; then 1.1570 + lnopt="$lnopt -s" 1.1571 + fi 1.1572 + 1.1573 + # iterate over sources 1.1574 + for src in $srcs; do 1.1575 + # determine if one of the paths is an absolute path, 1.1576 + # because then we _have_ to use an absolute symlink 1.1577 + oneisabs=0 1.1578 + srcisabs=0 1.1579 + dstisabs=0 1.1580 + case $src in 1.1581 + /* ) oneisabs=1; srcisabs=1 ;; 1.1582 + esac 1.1583 + case $dst in 1.1584 + /* ) oneisabs=1; dstisabs=1 ;; 1.1585 + esac 1.1586 + 1.1587 + # split source and destination into dir and base name 1.1588 + if [ -d $src ]; then 1.1589 + srcdir=`echo $src | sed -e 's;/*$;;'` 1.1590 + srcbase="" 1.1591 + else 1.1592 + srcdir=`echo $src | sed -e 's;^[^/]*$;;' -e 's;^\(.*/\)[^/]*$;\1;' -e 's;\(.\)/$;\1;'` 1.1593 + srcbase=`echo $src | sed -e 's;.*/\([^/]*\)$;\1;'` 1.1594 + fi 1.1595 + if [ -d $dst ]; then 1.1596 + dstdir=`echo $dst | sed -e 's;/*$;;'` 1.1597 + dstbase="" 1.1598 + else 1.1599 + dstdir=`echo $dst | sed -e 's;^[^/]*$;;' -e 's;^\(.*/\)[^/]*$;\1;' -e 's;\(.\)/$;\1;'` 1.1600 + dstbase=`echo $dst | sed -e 's;.*/\([^/]*\)$;\1;'` 1.1601 + fi 1.1602 + 1.1603 + # consistency check 1.1604 + if [ ".$dstdir" != . ]; then 1.1605 + if [ ! -d $dstdir ]; then 1.1606 + echo "$msgprefix:Error: destination directory not found: $dstdir" 1>&2 1.1607 + shtool_exit 1 1.1608 + fi 1.1609 + fi 1.1610 + 1.1611 + # make sure the source is reachable from the destination 1.1612 + if [ $dstisabs = 1 ]; then 1.1613 + if [ $srcisabs = 0 ]; then 1.1614 + if [ ".$srcdir" = . ]; then 1.1615 + srcdir="`pwd | sed -e 's;/*$;;'`" 1.1616 + srcisabs=1 1.1617 + oneisabs=1 1.1618 + elif [ -d $srcdir ]; then 1.1619 + srcdir="`cd $srcdir; pwd | sed -e 's;/*$;;'`" 1.1620 + srcisabs=1 1.1621 + oneisabs=1 1.1622 + fi 1.1623 + fi 1.1624 + fi 1.1625 + 1.1626 + # split away a common prefix 1.1627 + prefix="" 1.1628 + if [ ".$srcdir" = ".$dstdir" ] && [ ".$srcdir" != . ]; then 1.1629 + prefix="$srcdir/" 1.1630 + srcdir="" 1.1631 + dstdir="" 1.1632 + else 1.1633 + while [ ".$srcdir" != . ] && [ ".$dstdir" != . ]; do 1.1634 + presrc=`echo $srcdir | sed -e 's;^\([^/]*\)/.*;\1;'` 1.1635 + predst=`echo $dstdir | sed -e 's;^\([^/]*\)/.*;\1;'` 1.1636 + if [ ".$presrc" != ".$predst" ]; then 1.1637 + break 1.1638 + fi 1.1639 + prefix="$prefix$presrc/" 1.1640 + srcdir=`echo $srcdir | sed -e 's;^[^/]*/*;;'` 1.1641 + dstdir=`echo $dstdir | sed -e 's;^[^/]*/*;;'` 1.1642 + done 1.1643 + fi 1.1644 + 1.1645 + # destination prefix is just the common prefix 1.1646 + dstpre="$prefix" 1.1647 + 1.1648 + # determine source prefix which is the reverse directory 1.1649 + # step-up corresponding to the destination directory 1.1650 + srcpre="" 1.1651 + allow_relative_srcpre=no 1.1652 + if [ ".$prefix" != . ] && [ ".$prefix" != ./ ]; then 1.1653 + allow_relative_srcpre=yes 1.1654 + fi 1.1655 + if [ $oneisabs = 0 ]; then 1.1656 + allow_relative_srcpre=yes 1.1657 + fi 1.1658 + if [ ".$opt_s" != .yes ]; then 1.1659 + allow_relative_srcpre=no 1.1660 + fi 1.1661 + if [ ".$allow_relative_srcpre" = .yes ]; then 1.1662 + pl="$dstdir/" 1.1663 + OIFS="$IFS"; IFS='/' 1.1664 + for pe in $pl; do 1.1665 + [ ".$pe" = . ] && continue 1.1666 + [ ".$pe" = .. ] && continue 1.1667 + srcpre="../$srcpre" 1.1668 + done 1.1669 + IFS="$OIFS" 1.1670 + else 1.1671 + if [ $srcisabs = 1 ]; then 1.1672 + srcpre="$prefix" 1.1673 + fi 1.1674 + fi 1.1675 + 1.1676 + # determine destination symlink name 1.1677 + if [ ".$dstbase" = . ]; then 1.1678 + if [ ".$srcbase" != . ]; then 1.1679 + dstbase="$srcbase" 1.1680 + else 1.1681 + dstbase=`echo "$prefix$srcdir" | sed -e 's;/*$;;' -e 's;.*/\([^/]*\)$;\1;'` 1.1682 + fi 1.1683 + fi 1.1684 + 1.1685 + # now finalize source and destination directory paths 1.1686 + srcdir=`echo $srcdir | sed -e 's;\([^/]\)$;\1/;'` 1.1687 + dstdir=`echo $dstdir | sed -e 's;\([^/]\)$;\1/;'` 1.1688 + 1.1689 + # run the final link command 1.1690 + if [ ".$opt_t" = .yes ]; then 1.1691 + echo "ln$lnopt $srcpre$srcdir$srcbase $dstpre$dstdir$dstbase" 1.1692 + fi 1.1693 + eval ln$lnopt $srcpre$srcdir$srcbase $dstpre$dstdir$dstbase 1.1694 + done 1.1695 + 1.1696 + shtool_exit 0 1.1697 + ;; 1.1698 + 1.1699 +mkshadow ) 1.1700 + ## 1.1701 + ## mkshadow -- Make a shadow tree through symbolic links 1.1702 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1703 + ## 1.1704 + 1.1705 + # source and destination directory 1.1706 + src=`echo "$1" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'` 1.1707 + dst=`echo "$2" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'` 1.1708 + 1.1709 + # check whether source exists 1.1710 + if [ ! -d $src ]; then 1.1711 + echo "$msgprefix:Error: source directory not found: \`$src'" 1>&2 1.1712 + shtool_exit 1 1.1713 + fi 1.1714 + 1.1715 + # determine if one of the paths is an absolute path, 1.1716 + # because then we have to use an absolute symlink 1.1717 + oneisabs=0 1.1718 + case $src in 1.1719 + /* ) oneisabs=1 ;; 1.1720 + esac 1.1721 + case $dst in 1.1722 + /* ) oneisabs=1 ;; 1.1723 + esac 1.1724 + 1.1725 + # determine reverse directory for destination directory 1.1726 + dstrevdir='' 1.1727 + if [ $oneisabs = 0 ]; then 1.1728 + # derive reverse path from forward path 1.1729 + pwd=`pwd` 1.1730 + OIFS="$IFS"; IFS='/' 1.1731 + for pe in $dst; do 1.1732 + if [ "x$pe" = "x.." ]; then 1.1733 + OIFS2="$IFS"; IFS="$DIFS" 1.1734 + eval `echo "$pwd" |\ 1.1735 + sed -e 's:\([^/]*\)$:; dir="\1":' \ 1.1736 + -e 's:^\(.*\)/[^/]*;:pwd="\1";:'\ 1.1737 + -e 's:^;:pwd="";:'` 1.1738 + dstrevdir="$dir/$dstrevdir" 1.1739 + IFS="$OIFS2" 1.1740 + else 1.1741 + dstrevdir="../$dstrevdir" 1.1742 + fi 1.1743 + done 1.1744 + IFS="$OIFS" 1.1745 + else 1.1746 + src="`cd $src; pwd`"; 1.1747 + fi 1.1748 + 1.1749 + # create directory tree at destination 1.1750 + if [ ! -d $dst ]; then 1.1751 + if [ ".$opt_t" = .yes ]; then 1.1752 + echo "mkdir $dst" 1>&2 1.1753 + fi 1.1754 + mkdir $dst 1.1755 + fi 1.1756 + if [ ".$opt_a" = .yes ]; then 1.1757 + DIRS=`cd $src; find . -type d -print |\ 1.1758 + sed -e '/^\.$/d' -e 's:^\./::'` 1.1759 + else 1.1760 + DIRS=`cd $src; find . -type d -print |\ 1.1761 + sed -e '/\/CVS/d' -e '/^\.$/d' -e 's:^\./::'` 1.1762 + fi 1.1763 + for dir in $DIRS; do 1.1764 + if [ ".$opt_t" = .yes ]; then 1.1765 + echo "mkdir $dst/$dir" 1>&2 1.1766 + fi 1.1767 + mkdir $dst/$dir 1.1768 + done 1.1769 + 1.1770 + # fill directory tree with symlinks to files 1.1771 + if [ ".$opt_a" = .yes ]; then 1.1772 + FILES="`cd $src; find . -depth -print |\ 1.1773 + sed -e 's/^\.\///'`" 1.1774 + else 1.1775 + FILES="`cd $src; find . -depth -print |\ 1.1776 + sed -e '/\.o$/d' -e '/\.a$/d' -e '/\.so$/d' \ 1.1777 + -e '/\.cvsignore$/d' -e '/\/CVS/d' \ 1.1778 + -e '/\/\.#/d' -e '/\.orig$/d' \ 1.1779 + -e 's/^\.\///'`" 1.1780 + fi 1.1781 + for file in $FILES; do 1.1782 + # don't use `-type f' above for find because of symlinks 1.1783 + if [ -d "$src/$file" ]; then 1.1784 + continue 1.1785 + fi 1.1786 + basename=`echo $file | sed -e 's:^.*/::'` 1.1787 + dir=`echo $file | sed -e 's:[^/]*$::' -e 's:/$::' -e 's:$:/:' -e 's:^/$::'` 1.1788 + from=`echo "$src/$file" | sed -e 's/^\.\///'` 1.1789 + to="$dst/$dir$basename" 1.1790 + if [ $oneisabs = 0 ]; then 1.1791 + if [ ".$dir" != . ]; then 1.1792 + subdir=`echo $dir | sed -e 's:/$::'` 1.1793 + # derive reverse path from forward path 1.1794 + revdir='' 1.1795 + OIFS="$IFS"; IFS='/' 1.1796 + for pe in $subdir; do 1.1797 + revdir="../$revdir" 1.1798 + done 1.1799 + IFS="$OIFS" 1.1800 + # finalize from 1.1801 + from="$revdir$from" 1.1802 + fi 1.1803 + from="$dstrevdir$from" 1.1804 + fi 1.1805 + if [ ".$opt_v" = .yes ]; then 1.1806 + echo " $to" 1>&2 1.1807 + fi 1.1808 + if [ ".$opt_t" = .yes ]; then 1.1809 + echo "ln -s $from $to" 1>&2 1.1810 + fi 1.1811 + ln -s $from $to 1.1812 + done 1.1813 + 1.1814 + shtool_exit 0 1.1815 + ;; 1.1816 + 1.1817 +fixperm ) 1.1818 + ## 1.1819 + ## fixperm -- Fix file permissions inside a source tree 1.1820 + ## Copyright (c) 1996-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1821 + ## 1.1822 + 1.1823 + paths="$*" 1.1824 + 1.1825 + # check whether the test command supports the -x option 1.1826 + if [ -x /bin/sh ] 2>/dev/null; then 1.1827 + minusx="-x" 1.1828 + else 1.1829 + minusx="-r" 1.1830 + fi 1.1831 + 1.1832 + # iterate over paths 1.1833 + for p in $paths; do 1.1834 + for file in `find $p -depth -print`; do 1.1835 + if [ -f $file ]; then 1.1836 + if [ $minusx $file ]; then 1.1837 + if [ ".$opt_v" = .yes ]; then 1.1838 + echo "-rwxr-xr-x $file" 2>&1 1.1839 + fi 1.1840 + if [ ".$opt_t" = .yes ]; then 1.1841 + echo "chmod 755 $file" 2>&1 1.1842 + fi 1.1843 + chmod 755 $file 1.1844 + else 1.1845 + if [ ".$opt_v" = .yes ]; then 1.1846 + echo "-rw-r--r-- $file" 2>&1 1.1847 + fi 1.1848 + if [ ".$opt_t" = .yes ]; then 1.1849 + echo "chmod 644 $file" 2>&1 1.1850 + fi 1.1851 + chmod 644 $file 1.1852 + fi 1.1853 + continue 1.1854 + fi 1.1855 + if [ -d $file ]; then 1.1856 + if [ ".$opt_v" = .yes ]; then 1.1857 + echo "drwxr-xr-x $file" 2>&1 1.1858 + fi 1.1859 + if [ ".$opt_t" = .yes ]; then 1.1860 + echo "chmod 755 $file" 2>&1 1.1861 + fi 1.1862 + chmod 755 $file 1.1863 + continue 1.1864 + fi 1.1865 + if [ ".$opt_v" = .yes ]; then 1.1866 + echo "?????????? $file" 2>&1 1.1867 + fi 1.1868 + done 1.1869 + done 1.1870 + 1.1871 + shtool_exit 0 1.1872 + ;; 1.1873 + 1.1874 +rotate ) 1.1875 + ## 1.1876 + ## rotate -- Logfile rotation 1.1877 + ## Copyright (c) 2001-2007 Ralf S. Engelschall <rse@engelschall.com> 1.1878 + ## 1.1879 + 1.1880 + # make sure we have at least one file to rotate 1.1881 + if [ ".$opt_n" = .0 ]; then 1.1882 + echo "$msgprefix:Error: invalid argument \`$opt_n' to option -n." 1>&2 1.1883 + shtool_exit 1 1.1884 + fi 1.1885 + 1.1886 + # canonicalize -s option argument 1.1887 + if [ ".$opt_s" != . ]; then 1.1888 + if [ ".`expr $opt_s : '[0-9]*$'`" != .0 ]; then 1.1889 + : 1.1890 + elif [ ".`expr $opt_s : '[0-9]*[Kk]$'`" != .0 ]; then 1.1891 + opt_s=`expr $opt_s : '\([0-9]*\)[Kk]$'` 1.1892 + opt_s=`expr $opt_s \* 1024` 1.1893 + elif [ ".`expr $opt_s : '[0-9]*[Mm]$'`" != .0 ]; then 1.1894 + opt_s=`expr $opt_s : '\([0-9]*\)[Mm]$'` 1.1895 + opt_s=`expr $opt_s \* 1048576` # 1024*1024 1.1896 + elif [ ".`expr $opt_s : '[0-9]*[Gg]$'`" != .0 ]; then 1.1897 + opt_s=`expr $opt_s : '\([0-9]*\)[Gg]$'` 1.1898 + opt_s=`expr $opt_s \* 1073741824` # 1024*1024*1024 1.1899 + else 1.1900 + echo "$msgprefix:Error: invalid argument \`$opt_s' to option -s." 1>&2 1.1901 + shtool_exit 1 1.1902 + fi 1.1903 + fi 1.1904 + 1.1905 + # option -d/-z consistency 1.1906 + if [ ".$opt_d" = .yes ] && [ ".$opt_z" = . ]; then 1.1907 + echo "$msgprefix:Error: option -d requires option -z." 1>&2 1.1908 + shtool_exit 1 1.1909 + fi 1.1910 + 1.1911 + # make sure target directory exists 1.1912 + if [ ".$opt_a" != . ]; then 1.1913 + if [ ! -d $opt_a ]; then 1.1914 + if [ ".$opt_f" = .no ]; then 1.1915 + echo "$msgprefix:Error: archive directory \`$opt_a' does not exist." 1>&2 1.1916 + shtool_exit 1 1.1917 + fi 1.1918 + mkdir $opt_a || shtool_exit $? 1.1919 + chmod 755 $opt_a 1.1920 + fi 1.1921 + if [ ! -w $opt_a ]; then 1.1922 + echo "$msgprefix:Error: archive directory \`$opt_a' not writable." 1>&2 1.1923 + shtool_exit 1 1.1924 + fi 1.1925 + fi 1.1926 + 1.1927 + # determine compression approach 1.1928 + if [ ".$opt_z" != . ]; then 1.1929 + comp_lvl="$opt_z" 1.1930 + comp_prg="" 1.1931 + case $comp_lvl in 1.1932 + *:* ) eval `echo $comp_lvl |\ 1.1933 + sed -e 's%^\(.*\):\(.*\)$%comp_prg="\1"; comp_lvl="\2"%'` ;; 1.1934 + esac 1.1935 + 1.1936 + # compression level consistency 1.1937 + case $comp_lvl in 1.1938 + [0-9] ) 1.1939 + ;; 1.1940 + * ) echo "$msgprefix:Error: invalid compression level \`$comp_lvl'" 1>&2 1.1941 + shtool_exit 1 1.1942 + ;; 1.1943 + esac 1.1944 + 1.1945 + # determine a suitable compression tool 1.1946 + if [ ".$comp_prg" = . ]; then 1.1947 + # check whether the test command supports the -x option 1.1948 + if [ -x /bin/sh ] 2>/dev/null; then 1.1949 + minusx="-x" 1.1950 + else 1.1951 + minusx="-r" 1.1952 + fi 1.1953 + # search for tools in $PATH 1.1954 + paths="`echo $PATH |\ 1.1955 + sed -e 's%/*:%:%g' -e 's%/*$%%' \ 1.1956 + -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \ 1.1957 + -e 's/:/ /g'`" 1.1958 + for prg in bzip2 gzip compress; do 1.1959 + for path in $paths; do 1.1960 + if [ $minusx "$path/$prg" ] && [ ! -d "$path/$prg" ]; then 1.1961 + comp_prg="$prg" 1.1962 + break 1.1963 + fi 1.1964 + done 1.1965 + if [ ".$comp_prg" != . ]; then 1.1966 + break 1.1967 + fi 1.1968 + done 1.1969 + if [ ".$comp_prg" = . ]; then 1.1970 + echo "$msgprefix:Error: no suitable compression tool found in \$PATH" 1>&2 1.1971 + shtool_exit 1 1.1972 + fi 1.1973 + fi 1.1974 + 1.1975 + # determine standard compression extension 1.1976 + # and make sure it is a known tool 1.1977 + case $comp_prg in 1.1978 + */bzip2 | bzip2 ) comp_ext="bz2" comp_lvl="-$comp_lvl" ;; 1.1979 + */gzip | gzip ) comp_ext="gz" comp_lvl="-$comp_lvl" ;; 1.1980 + */compress | compress ) comp_ext="Z"; comp_lvl="" ;; 1.1981 + * ) echo "$msgprefix:Error: tool \`$comp_prg' is not a known compression tool" 1>&2 1.1982 + shtool_exit 1 1.1983 + ;; 1.1984 + esac 1.1985 + comp_suf=".$comp_ext" 1.1986 + fi 1.1987 + 1.1988 + # iterate over all given logfile arguments 1.1989 + for file in $*; do 1.1990 + # make sure the logfile exists 1.1991 + if [ ! -f $file ]; then 1.1992 + if [ ".$opt_f" = .yes ]; then 1.1993 + continue 1.1994 + fi 1.1995 + echo "$msgprefix:Error: logfile \`$file' not found" 1>&2 1.1996 + shtool_exit 1 1.1997 + fi 1.1998 + 1.1999 + # determine log directory (where original logfile is placed) 1.2000 + ldir="." 1.2001 + case $file in 1.2002 + */* ) eval `echo $file | sed -e 's%^\(.*\)/\([^/]*\)$%ldir="\1"; file="\2";%'` ;; 1.2003 + esac 1.2004 + 1.2005 + # determine archive directory (where rotated logfiles are placed) 1.2006 + adir="$ldir" 1.2007 + if [ ".$opt_a" != . ]; then 1.2008 + case "$opt_a" in 1.2009 + /* | ./* ) adir="$opt_a" ;; 1.2010 + * ) adir="$ldir/$opt_a" ;; 1.2011 + esac 1.2012 + fi 1.2013 + 1.2014 + # optionally take logfile size into account 1.2015 + if [ ".$opt_s" != . ]; then 1.2016 + # determine size of logfile 1.2017 + set -- `env -i /bin/ls -l "$ldir/$file" | sed -e "s;$ldir/$file;;" |\ 1.2018 + sed -e 's; -> .*$;;' -e 's;[ ][ ]*; ;g'` 1.2019 + n=`expr $# - 3` 1.2020 + eval "size=\`echo \${$n}\`" 1.2021 + 1.2022 + # skip logfile if size is still too small 1.2023 + if [ $size -lt $opt_s ]; then 1.2024 + if [ ".$opt_v" = .yes ]; then 1.2025 + echo "$ldir/$file: still too small in size -- skipping" 1.2026 + fi 1.2027 + continue 1.2028 + fi 1.2029 + fi 1.2030 + 1.2031 + # verbosity 1.2032 + if [ ".$opt_v" = .yes ]; then 1.2033 + echo "rotating $ldir/$file" 1.2034 + fi 1.2035 + 1.2036 + # execute prolog 1.2037 + if [ ".$opt_P" != . ]; then 1.2038 + if [ ".$opt_t" = .yes ]; then 1.2039 + echo "$opt_P" 1.2040 + fi 1.2041 + eval $opt_P 1.2042 + [ $? -ne 0 ] && shtool_exit $? 1.2043 + fi 1.2044 + 1.2045 + # kick away out-rotated logfile 1.2046 + n=`expr $opt_n - 1` 1.2047 + n=`echo dummy | awk "{ printf(\"%0${opt_p}d\", n); }" n=$n` 1.2048 + if [ -f "${adir}/${file}.${n}${comp_suf}" ]; then 1.2049 + # optionally migrate away the out-rotated logfile 1.2050 + if [ ".$opt_M" != . ]; then 1.2051 + if [ ".$opt_t" = .yes ]; then 1.2052 + echo "$opt_M ${adir}/${file}.${n}${comp_suf}" 1.2053 + fi 1.2054 + eval "$opt_M ${adir}/${file}.${n}${comp_suf}" 1.2055 + [ $? -ne 0 ] && shtool_exit $? 1.2056 + fi 1.2057 + # finally get rid of the out-rotated logfile 1.2058 + if [ ".$opt_t" = .yes ]; then 1.2059 + echo "rm -f ${adir}/${file}.${n}${comp_suf}" 1.2060 + fi 1.2061 + rm -f ${adir}/${file}.${n}${comp_suf} || shtool_exit $? 1.2062 + fi 1.2063 + 1.2064 + # rotate already archived logfiles 1.2065 + while [ $n -gt 0 ]; do 1.2066 + m=$n 1.2067 + n=`expr $n - 1` 1.2068 + n=`echo dummy | awk "{ printf(\"%0${opt_p}d\", n); }" n=$n` 1.2069 + if [ $n -eq 0 ] && [ ".$opt_d" = .yes ]; then 1.2070 + # special case: first rotation file under delayed compression situation 1.2071 + if [ ! -f "${adir}/${file}.${n}" ]; then 1.2072 + continue 1.2073 + fi 1.2074 + 1.2075 + # compress file (delayed) 1.2076 + if [ ".$opt_b" = .yes ]; then 1.2077 + if [ ".$opt_t" = .yes ]; then 1.2078 + echo "mv ${adir}/${file}.${n} ${adir}/${file}.${m}" 1.2079 + fi 1.2080 + mv ${adir}/${file}.${n} ${adir}/${file}.${m} || shtool_exit $? 1.2081 + if [ ".$opt_t" = .yes ]; then 1.2082 + echo "(${comp_prg} ${comp_lvl} <${adir}/${file}.${m} >${adir}/${file}.${m}${comp_suf}; rm -f ${adir}/${file}.${m}) &" 1.2083 + fi 1.2084 + ( ${comp_prg} ${comp_lvl} \ 1.2085 + <${adir}/${file}.${m} \ 1.2086 + >${adir}/${file}.${m}${comp_suf} || shtool_exit $? 1.2087 + rm -f ${adir}/${file}.${m} || shtool_exit $? 1.2088 + ) </dev/null >/dev/null 2>&1 & 1.2089 + else 1.2090 + if [ ".$opt_t" = .yes ]; then 1.2091 + echo "${comp_prg} ${comp_lvl} <${adir}/${file}.${n} >${adir}/${file}.${m}${comp_suf}" 1.2092 + fi 1.2093 + ${comp_prg} ${comp_lvl} \ 1.2094 + <${adir}/${file}.${n} \ 1.2095 + >${adir}/${file}.${m}${comp_suf} || shtool_exit $? 1.2096 + if [ ".$opt_t" = .yes ]; then 1.2097 + echo "rm -f ${adir}/${file}.${n}" 1.2098 + fi 1.2099 + rm -f ${adir}/${file}.${n} || shtool_exit $? 1.2100 + fi 1.2101 + 1.2102 + # fix file attributes 1.2103 + if [ ".$opt_o" != . ]; then 1.2104 + if [ ".$opt_t" = .yes ]; then 1.2105 + echo "chown $opt_o ${adir}/${file}.${m}${comp_suf}" 1.2106 + fi 1.2107 + chown $opt_o ${adir}/${file}.${m}${comp_suf} || shtool_exit $? 1.2108 + fi 1.2109 + if [ ".$opt_g" != . ]; then 1.2110 + if [ ".$opt_t" = .yes ]; then 1.2111 + echo "chgrp $opt_g ${adir}/${file}.${m}${comp_suf}" 1.2112 + fi 1.2113 + chgrp $opt_g ${adir}/${file}.${m}${comp_suf} || shtool_exit $? 1.2114 + fi 1.2115 + if [ ".$opt_m" != . ]; then 1.2116 + if [ ".$opt_t" = .yes ]; then 1.2117 + echo "chmod $opt_m ${adir}/${file}.${m}${comp_suf}" 1.2118 + fi 1.2119 + chmod $opt_m ${adir}/${file}.${m}${comp_suf} || shtool_exit $? 1.2120 + fi 1.2121 + else 1.2122 + # standard case: second and following rotation file 1.2123 + if [ ! -f "${adir}/${file}.${n}${comp_suf}" ]; then 1.2124 + continue 1.2125 + fi 1.2126 + if [ ".$opt_t" = .yes ]; then 1.2127 + echo "mv ${adir}/${file}.${n}${comp_suf} ${adir}/${file}.${m}${comp_suf}" 1.2128 + fi 1.2129 + mv ${adir}/${file}.${n}${comp_suf} ${adir}/${file}.${m}${comp_suf} || shtool_exit $? 1.2130 + fi 1.2131 + done 1.2132 + 1.2133 + # move away current logfile 1.2134 + if [ ".$opt_c" = .yes ]; then 1.2135 + # approach: copy[+truncate] 1.2136 + if [ ".$opt_t" = .yes ]; then 1.2137 + echo "cp -p ${ldir}/${file} ${adir}/${file}.${n}" 1.2138 + fi 1.2139 + cp -p ${ldir}/${file} ${adir}/${file}.${n} || shtool_exit $? 1.2140 + if [ ".$opt_r" = .no ]; then 1.2141 + if [ ".$opt_t" = .yes ]; then 1.2142 + echo "cp /dev/null ${ldir}/${file}" 1.2143 + fi 1.2144 + cp /dev/null ${ldir}/${file} || shtool_exit $? 1.2145 + fi 1.2146 + else 1.2147 + # approach: move[+touch] 1.2148 + if [ ".$opt_t" = .yes ]; then 1.2149 + echo "mv ${ldir}/${file} ${adir}/${file}.${n}" 1.2150 + fi 1.2151 + mv ${ldir}/${file} ${adir}/${file}.${n} || shtool_exit $? 1.2152 + if [ ".$opt_r" = .no ]; then 1.2153 + if [ ".$opt_t" = .yes ]; then 1.2154 + echo "touch ${ldir}/${file}" 1.2155 + fi 1.2156 + touch ${ldir}/${file} || shtool_exit $? 1.2157 + # fix file attributes 1.2158 + if [ ".$opt_o" != . ]; then 1.2159 + if [ ".$opt_t" = .yes ]; then 1.2160 + echo "chown $opt_o ${ldir}/${file}" 1.2161 + fi 1.2162 + chown $opt_o ${ldir}/${file} || shtool_exit $? 1.2163 + fi 1.2164 + if [ ".$opt_g" != . ]; then 1.2165 + if [ ".$opt_t" = .yes ]; then 1.2166 + echo "chgrp $opt_g ${ldir}/${file}" 1.2167 + fi 1.2168 + chgrp $opt_g ${ldir}/${file} || shtool_exit $? 1.2169 + fi 1.2170 + if [ ".$opt_m" != . ]; then 1.2171 + if [ ".$opt_t" = .yes ]; then 1.2172 + echo "chmod $opt_m ${ldir}/${file}" 1.2173 + fi 1.2174 + chmod $opt_m ${ldir}/${file} || shtool_exit $? 1.2175 + fi 1.2176 + fi 1.2177 + fi 1.2178 + 1.2179 + # regular compression step 1.2180 + if [ ".$opt_z" != . ] && [ ".$opt_d" = .no ]; then 1.2181 + # compress file 1.2182 + if [ ".$opt_b" = .yes ]; then 1.2183 + if [ ".$opt_t" = .yes ]; then 1.2184 + echo "(${comp_prg} ${comp_lvl} <${adir}/${file}.${n} >${adir}/${file}.${n}${comp_suf}; rm -f ${adir}/${file}.${n}) &" 1.2185 + fi 1.2186 + ( ${comp_prg} ${comp_lvl} \ 1.2187 + <${adir}/${file}.${n} \ 1.2188 + >${adir}/${file}.${n}${comp_suf} || shtool_exit $? 1.2189 + rm -f ${adir}/${file}.${n} || shtool_exit $? 1.2190 + ) </dev/null >/dev/null 2>&1 & 1.2191 + else 1.2192 + if [ ".$opt_t" = .yes ]; then 1.2193 + echo "${comp_prg} ${comp_lvl} <${adir}/${file}.${n} >${adir}/${file}.${n}${comp_suf}" 1.2194 + fi 1.2195 + ${comp_prg} ${comp_lvl} \ 1.2196 + <${adir}/${file}.${n} \ 1.2197 + >${adir}/${file}.${n}${comp_suf} || shtool_exit $? 1.2198 + if [ ".$opt_t" = .yes ]; then 1.2199 + echo "rm -f ${opt_a}${file}.${n}" 1.2200 + fi 1.2201 + rm -f ${adir}/${file}.${n} || shtool_exit $? 1.2202 + fi 1.2203 + 1.2204 + # fix file attributes 1.2205 + if [ ".$opt_o" != . ]; then 1.2206 + if [ ".$opt_t" = .yes ]; then 1.2207 + echo "chown $opt_o ${adir}/${file}.${n}${comp_suf}" 1.2208 + fi 1.2209 + chown $opt_o ${adir}/${file}.${n}${comp_suf} || shtool_exit $? 1.2210 + fi 1.2211 + if [ ".$opt_g" != . ]; then 1.2212 + if [ ".$opt_t" = .yes ]; then 1.2213 + echo "chgrp $opt_g ${adir}/${file}.${n}${comp_suf}" 1.2214 + fi 1.2215 + chgrp $opt_g ${adir}/${file}.${n}${comp_suf} || shtool_exit $? 1.2216 + fi 1.2217 + if [ ".$opt_m" != . ]; then 1.2218 + if [ ".$opt_t" = .yes ]; then 1.2219 + echo "chmod $opt_m ${adir}/${file}.${n}${comp_suf}" 1.2220 + fi 1.2221 + chmod $opt_m ${adir}/${file}.${n}${comp_suf} || shtool_exit $? 1.2222 + fi 1.2223 + fi 1.2224 + 1.2225 + # execute epilog 1.2226 + if [ ".$opt_E" != . ]; then 1.2227 + if [ ".$opt_t" = .yes ]; then 1.2228 + echo "$opt_E" 1.2229 + fi 1.2230 + eval $opt_E 1.2231 + [ $? -ne 0 ] && shtool_exit $? 1.2232 + fi 1.2233 + done 1.2234 + 1.2235 + shtool_exit 0 1.2236 + ;; 1.2237 + 1.2238 +tarball ) 1.2239 + ## 1.2240 + ## tarball -- Roll distribution tarballs 1.2241 + ## Copyright (c) 1999-2007 Ralf S. Engelschall <rse@engelschall.com> 1.2242 + ## 1.2243 + 1.2244 + srcs="$*" 1.2245 + 1.2246 + # check whether the test command supports the -x option 1.2247 + if [ -x /bin/sh ] 2>/dev/null; then 1.2248 + minusx="-x" 1.2249 + else 1.2250 + minusx="-r" 1.2251 + fi 1.2252 + 1.2253 + # find the tools 1.2254 + paths="`echo $PATH |\ 1.2255 + sed -e 's%/*:%:%g' -e 's%/*$%%' \ 1.2256 + -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \ 1.2257 + -e 's/:/ /g'`" 1.2258 + for spec in find:gfind,find tar:gtar,tar tardy:tardy,tarcust; do 1.2259 + prg=`echo $spec | sed -e 's/:.*$//'` 1.2260 + tools=`echo $spec | sed -e 's/^.*://'` 1.2261 + eval "prg_${prg}=''" 1.2262 + # iterate over tools 1.2263 + for tool in `echo $tools | sed -e 's/,/ /g'`; do 1.2264 + # iterate over paths 1.2265 + for path in $paths; do 1.2266 + if [ $minusx "$path/$tool" ] && [ ! -d "$path/$tool" ]; then 1.2267 + eval "prg_${prg}=\"$path/$tool\"" 1.2268 + break 1.2269 + fi 1.2270 + done 1.2271 + eval "val=\$prg_${prg}" 1.2272 + if [ ".$val" != . ]; then 1.2273 + break 1.2274 + fi 1.2275 + done 1.2276 + done 1.2277 + 1.2278 + # expand source paths 1.2279 + exclude='' 1.2280 + for pat in `echo $opt_e | sed 's/,/ /g'`; do 1.2281 + exclude="$exclude | grep -v '$pat'" 1.2282 + done 1.2283 + if [ ".$opt_t" = .yes ]; then 1.2284 + echo "cp /dev/null $tmpfile.lst" 1>&2 1.2285 + fi 1.2286 + cp /dev/null $tmpfile.lst 1.2287 + for src in $srcs; do 1.2288 + if [ -d $src ]; then 1.2289 + if [ ".$opt_t" = .yes ]; then 1.2290 + echo "(cd $src && $prg_find . -type f -depth -print) | sed -e 's:^\\.\$::' -e 's:^\\./::' | cat $exclude >>$tmpfile.lst" 1>&2 1.2291 + fi 1.2292 + (cd $src && $prg_find . -type f -depth -print) |\ 1.2293 + sed -e 's:^\.$::' -e 's:^\./::' | eval cat $exclude >>$tmpfile.lst 1.2294 + else 1.2295 + if [ ".$opt_t" = .yes ]; then 1.2296 + echo "echo $src >>$tmpfile.lst" 1>&2 1.2297 + fi 1.2298 + echo $src >>$tmpfile.lst 1.2299 + fi 1.2300 + done 1.2301 + sort <$tmpfile.lst >$tmpfile.lst.n 1.2302 + mv $tmpfile.lst.n $tmpfile.lst 1.2303 + if [ ".$opt_v" = .yes ]; then 1.2304 + cat $tmpfile.lst | sed -e 's/^/ /' 1>&2 1.2305 + fi 1.2306 + 1.2307 + # determine tarball file and directory name 1.2308 + if [ ".$opt_o" != . ]; then 1.2309 + tarfile="$opt_o" 1.2310 + if [ ".$opt_d" != . ]; then 1.2311 + tarname="$opt_d" 1.2312 + else 1.2313 + tarname=`echo $tarfile | sed -e 's/\.tar.*$//' -e 's;.*/\([^/]*\)$;\1;'` 1.2314 + fi 1.2315 + else 1.2316 + if [ ".$opt_d" != . ]; then 1.2317 + tarname="$opt_d" 1.2318 + elif [ -d "$from" ]; then 1.2319 + tarname=`echo $from | sed -e 's;.*/\([^/]*\)$;\1;'` 1.2320 + else 1.2321 + tarname="out" 1.2322 + fi 1.2323 + tarfile="$tarname.tar" 1.2324 + fi 1.2325 + 1.2326 + # roll the tarball 1.2327 + compress='' 1.2328 + if [ ".$opt_c" != . ]; then 1.2329 + compress="| $opt_c" 1.2330 + fi 1.2331 + if [ ".$prg_tardy" != . ]; then 1.2332 + # the elegant hackers way 1.2333 + tardy_opt="--prefix=$tarname" 1.2334 + tardy_opt="$tardy_opt --user_number=0 --group_number=0" # security! 1.2335 + if [ ".$opt_u" != . ]; then 1.2336 + tardy_opt="$tardy_opt --user_name=$opt_u" 1.2337 + fi 1.2338 + if [ ".$opt_g" != . ]; then 1.2339 + tardy_opt="$tardy_opt --group_name=$opt_g" 1.2340 + fi 1.2341 + if [ ".$opt_t" = .yes ]; then 1.2342 + echo "cat $tmpfile.lst | xargs $prg_tar cf - | $prg_tardy $tardy_opt | cat $compress >$tmpfile.out" 1>&2 1.2343 + fi 1.2344 + cat $tmpfile.lst |\ 1.2345 + xargs $prg_tar cf - |\ 1.2346 + $prg_tardy $tardy_opt |\ 1.2347 + eval cat $compress >$tmpfile.out 1.2348 + if [ ".$opt_t" = .yes ]; then 1.2349 + echo "cp $tmpfile.out $tarfile" 1>&2 1.2350 + fi 1.2351 + cp $tmpfile.out $tarfile 1.2352 + else 1.2353 + # the portable standard way 1.2354 + if [ ".$opt_t" = .yes ]; then 1.2355 + echo "mkdir $tmpdir/$tarname" 1>&2 1.2356 + fi 1.2357 + mkdir $tmpdir/$tarname || shtool_exit 1 1.2358 + if [ ".$opt_t" = .yes ]; then 1.2359 + echo "cat $tmpfile.lst | xargs $prg_tar cf - | (cd $tmpdir/$tarname && $prg_tar xf -)" 1>&2 1.2360 + fi 1.2361 + cat $tmpfile.lst |\ 1.2362 + xargs $prg_tar cf - |\ 1.2363 + (cd $tmpdir/$tarname && $prg_tar xf -) 1.2364 + if [ ".$opt_u" != . ]; then 1.2365 + if [ ".$opt_t" = .yes ]; then 1.2366 + echo "chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1" 2>&1 1.2367 + fi 1.2368 + chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1 ||\ 1.2369 + echo "$msgprefix:Warning: cannot set user name \`$opt_u' (would require root privileges)" 1.2370 + fi 1.2371 + if [ ".$opt_g" != . ]; then 1.2372 + if [ ".$opt_t" = .yes ]; then 1.2373 + echo "chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1" 2>&1 1.2374 + fi 1.2375 + chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1 ||\ 1.2376 + echo "$msgprefix:Warning: cannot set group name \`$opt_g' (would require root privileges)" 1.2377 + fi 1.2378 + if [ ".$opt_t" = .yes ]; then 1.2379 + echo "(cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) | cat $compress >$tmpfile.out" 1>&2 1.2380 + fi 1.2381 + (cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) |\ 1.2382 + eval cat $compress >$tmpfile.out 1.2383 + if [ ".$opt_t" = .yes ]; then 1.2384 + echo "cp $tmpfile.out $tarfile" 1>&2 1.2385 + fi 1.2386 + cp $tmpfile.out $tarfile 1.2387 + if [ ".$opt_t" = .yes ]; then 1.2388 + echo "rm -rf $tmpdir/$tarname" 1>&2 1.2389 + fi 1.2390 + rm -rf $tmpdir/$tarname 1.2391 + fi 1.2392 + 1.2393 + # cleanup 1.2394 + if [ ".$opt_t" = .yes ]; then 1.2395 + echo "rm -f $tmpfile.lst $tmpfile.out" 1>&2 1.2396 + fi 1.2397 + rm -f $tmpfile.lst $tmpfile.out 1.2398 + 1.2399 + shtool_exit 0 1.2400 + ;; 1.2401 + 1.2402 +subst ) 1.2403 + ## 1.2404 + ## subst -- Apply sed(1) substitution operations 1.2405 + ## Copyright (c) 2001-2007 Ralf S. Engelschall <rse@engelschall.com> 1.2406 + ## 1.2407 + 1.2408 + # remember optional list of file(s) 1.2409 + files="$*" 1.2410 + files_num="$#" 1.2411 + 1.2412 + # parameter consistency check 1.2413 + if [ $# -eq 0 ] && [ ".$opt_b" != . ]; then 1.2414 + echo "$msgprefix:Error: option -b cannot be applied to stdin" 1>&2 1.2415 + shtool_exit 1 1.2416 + fi 1.2417 + if [ $# -eq 0 ] && [ ".$opt_s" = .yes ]; then 1.2418 + echo "$msgprefix:Error: option -s cannot be applied to stdin" 1>&2 1.2419 + shtool_exit 1 1.2420 + fi 1.2421 + 1.2422 + # build underlying sed(1) command 1.2423 + sedcmd='sed' 1.2424 + if [ ".$opt_e" != . ]; then 1.2425 + OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS" 1.2426 + for e 1.2427 + do 1.2428 + sedcmd="$sedcmd -e '$e'" 1.2429 + done 1.2430 + elif [ ".$opt_f" != . ]; then 1.2431 + if [ ! -f $opt_f ]; then 1.2432 + echo "$msgprefix:Error: command file \`$opt_f' not found or not a regular file" 1>&2 1.2433 + shtool_exit 1 1.2434 + fi 1.2435 + sedcmd="$sedcmd -f '$opt_f'" 1.2436 + else 1.2437 + echo "$msgprefix:Error: either -e option(s) or -f option required" 1>&2 1.2438 + shtool_exit 1 1.2439 + fi 1.2440 + 1.2441 + # determine extension for original file 1.2442 + orig=".orig" 1.2443 + if [ ".$opt_b" != . ]; then 1.2444 + orig="$opt_b" 1.2445 + fi 1.2446 + 1.2447 + # apply sed(1) operation(s) 1.2448 + if [ ".$files" != . ]; then 1.2449 + # apply operation(s) to files 1.2450 + substdone=no 1.2451 + for file in $files; do 1.2452 + test ".$file" = . && continue 1.2453 + if [ ! -f $file ]; then 1.2454 + echo "$msgprefix:Warning: file \`$file' not found or not a regular file" 1>&2 1.2455 + continue 1.2456 + fi 1.2457 + 1.2458 + # handle interactive mode 1.2459 + if [ ".$opt_i" = .yes ]; then 1.2460 + eval "$sedcmd <$file >$file.new" 1.2461 + skip=no 1.2462 + if cmp $file $file.new >/dev/null 2>&1; then 1.2463 + rm -f $file.new 1.2464 + skip=yes 1.2465 + else 1.2466 + (diff -U1 $file $file.new >$tmpfile) 2>/dev/null 1.2467 + if [ ".`cat $tmpfile`" = . ]; then 1.2468 + (diff -C1 $file $file.new >$tmpfile) 2>/dev/null 1.2469 + if [ ".`cat $tmpfile`" = . ]; then 1.2470 + echo "$msgprefix:Warning: unable to show difference for file \`$file'" 1>&2 1.2471 + cp /dev/null $tmpfile 1.2472 + fi 1.2473 + fi 1.2474 + rm -f $file.new 1.2475 + cat $tmpfile 1.2476 + echo dummy | awk '{ printf("%s", TEXT); }' TEXT=">>> Apply [Y/n]: " 1.2477 + read input 1.2478 + if [ ".$input" != .Y ] &&\ 1.2479 + [ ".$input" != .y ] &&\ 1.2480 + [ ".$input" != . ]; then 1.2481 + skip=yes 1.2482 + fi 1.2483 + fi 1.2484 + if [ ".$skip" = .yes ]; then 1.2485 + if [ ".$opt_v" = .yes ]; then 1.2486 + echo "file \`$file' -- skipped" 1>&2 1.2487 + fi 1.2488 + continue 1.2489 + fi 1.2490 + fi 1.2491 + 1.2492 + # apply sed(1) operation(s) 1.2493 + if [ ".$opt_v" = .yes ]; then 1.2494 + echo "patching \`$file'" 1>&2 1.2495 + fi 1.2496 + if [ ".$opt_t" = .yes ]; then 1.2497 + echo "\$ cp -p $file $file$orig" 1.2498 + echo "\$ chmod u+w $file" 1.2499 + echo "\$ $sedcmd <$file$orig >$file" 1.2500 + fi 1.2501 + if [ ".$opt_n" = .no ]; then 1.2502 + cp -p $file $file$orig 1.2503 + chmod u+w $file >/dev/null 2>&1 || true 1.2504 + eval "$sedcmd <$file$orig >$file" 1.2505 + fi 1.2506 + 1.2507 + # optionally fix timestamp 1.2508 + if [ ".$opt_s" = .yes ]; then 1.2509 + if [ ".$opt_t" = .yes ]; then 1.2510 + echo "\$ touch -r $file$orig $file" 1.2511 + fi 1.2512 + if [ ".$opt_n" = .no ]; then 1.2513 + touch -r $file$orig $file 1.2514 + fi 1.2515 + fi 1.2516 + 1.2517 + # optionally check whether any content change actually occurred 1.2518 + if [ ".$opt_q" = .no ]; then 1.2519 + if cmp $file$orig $file >/dev/null 2>&1; then 1.2520 + if [ ".$opt_w" = .yes ]; then 1.2521 + echo "$msgprefix:Warning: substitution resulted in no content change on file \"$file\"" 1>&2 1.2522 + fi 1.2523 + else 1.2524 + substdone=yes 1.2525 + fi 1.2526 + fi 1.2527 + 1.2528 + # optionally remove preserved original file 1.2529 + if [ ".$opt_b" = . ]; then 1.2530 + if [ ".$opt_t" = .yes ]; then 1.2531 + echo "\$ rm -f $file$orig" 1.2532 + fi 1.2533 + if [ ".$opt_n" = .no ]; then 1.2534 + rm -f $file$orig 1.2535 + fi 1.2536 + fi 1.2537 + done 1.2538 + if [ ".$opt_q" = .no ] && [ ".$opt_w" = .no ]; then 1.2539 + if [ ".$substdone" = .no ]; then 1.2540 + if [ ".$files_num" = .1 ]; then 1.2541 + echo "$msgprefix:Warning: substitution resulted in no content change on file \"$file\"" 1>&2 1.2542 + else 1.2543 + echo "$msgprefix:Warning: substitution resulted in no content change on any file" 1>&2 1.2544 + fi 1.2545 + fi 1.2546 + fi 1.2547 + else 1.2548 + # apply operation(s) to stdin/stdout 1.2549 + if [ ".$opt_v" = .yes ]; then 1.2550 + echo "patching <stdin>" 1>&2 1.2551 + fi 1.2552 + if [ ".$opt_t" = .yes ]; then 1.2553 + echo "\$ $sedcmd" 1.2554 + fi 1.2555 + if [ ".$opt_n" = .no ]; then 1.2556 + eval "$sedcmd" 1.2557 + fi 1.2558 + fi 1.2559 + 1.2560 + shtool_exit 0 1.2561 + ;; 1.2562 + 1.2563 +platform ) 1.2564 + ## 1.2565 + ## platform -- Platform Identification Utility 1.2566 + ## Copyright (c) 2003-2007 Ralf S. Engelschall <rse@engelschall.com> 1.2567 + ## 1.2568 + 1.2569 + # option post-processing 1.2570 + if [ ".$opt_t" != . ]; then 1.2571 + case "$opt_t" in 1.2572 + binary ) 1.2573 + # binary package id (OpenPKG RPM) 1.2574 + opt_F="%<ap>-%<sp>" 1.2575 + opt_L=yes 1.2576 + opt_S="" 1.2577 + opt_C="+" 1.2578 + ;; 1.2579 + build ) 1.2580 + # build time checking (OpenPKG RPM) 1.2581 + opt_F="%<at>-%<st>" 1.2582 + opt_L=yes 1.2583 + opt_S="" 1.2584 + opt_C="+" 1.2585 + ;; 1.2586 + gnu ) 1.2587 + # GNU config.guess style <arch>-<vendor>-<os><osversion> 1.2588 + opt_F="%<at>-unknown-%<st>" 1.2589 + opt_L=yes 1.2590 + opt_S="" 1.2591 + opt_C="+" 1.2592 + ;; 1.2593 + web ) 1.2594 + # non-whitespace HTTP Server-header id 1.2595 + opt_F="%<sp>-%<ap>" 1.2596 + opt_S="/" 1.2597 + opt_C="+" 1.2598 + ;; 1.2599 + summary) 1.2600 + # human readable verbose summary information 1.2601 + opt_F="Class: %[sc] (%[ac])\\nProduct: %[sp] (%[ap])\\nTechnology: %[st] (%[at])" 1.2602 + opt_S=" " 1.2603 + opt_C="/" 1.2604 + ;; 1.2605 + all-in-one ) 1.2606 + # full-table all-in-one information 1.2607 + opt_F="" 1.2608 + opt_F="${opt_F}concise architecture class: %<ac>\\n" 1.2609 + opt_F="${opt_F}regular architecture class: %{ac}\\n" 1.2610 + opt_F="${opt_F}verbose architecture class: %[ac]\\n" 1.2611 + opt_F="${opt_F}concise architecture product: %<ap>\\n" 1.2612 + opt_F="${opt_F}regular architecture product: %{ap}\\n" 1.2613 + opt_F="${opt_F}verbose architecture product: %[ap]\\n" 1.2614 + opt_F="${opt_F}concise architecture technology: %<at>\\n" 1.2615 + opt_F="${opt_F}regular architecture technology: %{at}\\n" 1.2616 + opt_F="${opt_F}verbose architecture technology: %[at]\\n" 1.2617 + opt_F="${opt_F}concise system class: %<sc>\\n" 1.2618 + opt_F="${opt_F}regular system class: %{sc}\\n" 1.2619 + opt_F="${opt_F}verbose system class: %[sc]\\n" 1.2620 + opt_F="${opt_F}concise system product: %<sp>\\n" 1.2621 + opt_F="${opt_F}regular system product: %{sp}\\n" 1.2622 + opt_F="${opt_F}verbose system product: %[sp]\\n" 1.2623 + opt_F="${opt_F}concise system technology: %<st>\\n" 1.2624 + opt_F="${opt_F}regular system technology: %{st}\\n" 1.2625 + opt_F="${opt_F}verbose system technology: %[st]" 1.2626 + ;; 1.2627 + * ) 1.2628 + echo "$msgprefix:Error: invalid type \`$opt_t'" 1>&2 1.2629 + exit 1 1.2630 + ;; 1.2631 + esac 1.2632 + fi 1.2633 + 1.2634 + # assemble initial platform information 1.2635 + UNAME_MACHINE=`(uname -m) 2>/dev/null` ||\ 1.2636 + UNAME_MACHINE=`(uname -p) 2>/dev/null` ||\ 1.2637 + UNAME_MACHINE='unknown' 1.2638 + UNAME_SYSTEM=`(uname -s) 2>/dev/null` ||\ 1.2639 + UNAME_SYSTEM='unknown' 1.2640 + UNAME_RELEASE=`(uname -r) 2>/dev/null` ||\ 1.2641 + UNAME_RELEASE=`(uname -v) 2>/dev/null` ||\ 1.2642 + UNAME_RELEASE='unknown' 1.2643 + 1.2644 + UNAME="${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}" 1.2645 + 1.2646 + AC=""; AP=""; AT="" 1.2647 + SC=""; SP=""; ST="" 1.2648 + 1.2649 + # dispatch into platform specific sections 1.2650 + case "${UNAME}" in 1.2651 + 1.2652 + # FreeBSD 1.2653 + *:FreeBSD:* ) 1.2654 + # determine architecture 1.2655 + AC="${UNAME_MACHINE}" 1.2656 + case "${AC}" in 1.2657 + i386 ) AC="iX86" ;; 1.2658 + esac 1.2659 + AP="${AC}" 1.2660 + AT="${AP}" 1.2661 + if [ ".${AT}" = ".iX86" ]; then 1.2662 + case "`(/sbin/sysctl -n hw.model) 2>&1`" in 1.2663 + *"Xeon"* | *"Pentium Pro"* | *"Cyrix 6x86MX"* | *"Pentium II"* | *"Pentium III"* | *"Pentium 4"* | *"Celeron"* ) AT="i686" ;; 1.2664 + *"Pentium"* ) AT="i586" ;; *"i486[SD]X"* | *"Cyrix 486"* | *"Cyrix [56]x86"* | *"Blue Lightning" | *"Cyrix 486S/DX" ) AT="i486" ;; 1.2665 + *"i386[SD]X"* | *"NexGen 586"* ) AT="i386" ;; 1.2666 + esac 1.2667 + fi 1.2668 + # determine system 1.2669 + r=`echo "${UNAME_RELEASE}" |\ 1.2670 + sed -e 's;[()];;' -e 's/\(-.*\)$/[\1]/'` 1.2671 + ST="FreeBSD ${r}" 1.2672 + SP="${ST}" 1.2673 + case "${r}" in 1.2674 + 1.* ) SC="4.3BSD" ;; 1.2675 + * ) SC="4.4BSD" ;; 1.2676 + esac 1.2677 + ;; 1.2678 + 1.2679 + # NetBSD 1.2680 + *:NetBSD:* ) 1.2681 + # determine architecture 1.2682 + AT="${UNAME_MACHINE}" 1.2683 + AP="${AT}" 1.2684 + case "${AP}" in 1.2685 + i[3-6]86 ) AP="iX86" ;; 1.2686 + esac 1.2687 + AC="${AP}" 1.2688 + # determine system 1.2689 + r=`echo "${UNAME_RELEASE}" | sed -e 's/\([-_].*\)$/[\1]/'` 1.2690 + ST="NetBSD ${r}" 1.2691 + SP="${ST}" 1.2692 + case "${r}" in 1.2693 + 0.* ) SC="4.3BSD" ;; 1.2694 + * ) SC="4.4BSD" ;; 1.2695 + esac 1.2696 + ;; 1.2697 + 1.2698 + # OpenBSD 1.2699 + *:OpenBSD:* ) 1.2700 + # determine architecture 1.2701 + AT="${UNAME_MACHINE}" 1.2702 + AP="${AT}" 1.2703 + case "${AP}" in 1.2704 + i[3-6]86 ) AP="iX86" ;; 1.2705 + esac 1.2706 + AC="${AP}" 1.2707 + # determine system 1.2708 + r=`echo "${UNAME_RELEASE}" | sed -e 's/\([-_].*\)$/[\1]/'` 1.2709 + ST="OpenBSD ${r}" 1.2710 + SP="${ST}" 1.2711 + SC="4.4BSD" 1.2712 + ;; 1.2713 + 1.2714 + # GNU/Linux 1.2715 + *:Linux:* ) 1.2716 + # determine architecture 1.2717 + AT="${UNAME_MACHINE}" 1.2718 + case "${AT}" in 1.2719 + ia64 ) AT="IA64" ;; 1.2720 + x86_64 ) AT='AMD64' ;; 1.2721 + parisc ) AT="HPPA32" ;; 1.2722 + parisc64 ) AT="HPPA64" ;; 1.2723 + esac 1.2724 + AP="${AT}" 1.2725 + case "${AP}" in 1.2726 + i[3-6]86 ) AP='iX86' ;; 1.2727 + esac 1.2728 + AC="${AP}" 1.2729 + # determine system 1.2730 + v_kern=`echo "${UNAME_RELEASE}" |\ 1.2731 + sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'` 1.2732 + v_libc=`(strings /lib/libc.so.* | grep '^GLIBC_' | sed -e 's/^GLIBC_//' |\ 1.2733 + env -i sort -n | sed -n -e '$p' | sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/') 2>/dev/null` 1.2734 + ST="GNU/<Linux >${v_libc}/<${v_kern}>" 1.2735 + if [ -f /etc/lsb-release ]; then 1.2736 + eval `( . /etc/lsb-release 1.2737 + echo "SC=\"LSB${LSB_VERSION}\"" 1.2738 + if [ ".${DISTRIB_ID}" != . -a ".${DISTRIB_RELEASE}" != . ]; then 1.2739 + echo "SP=\"${DISTRIB_ID} ${DISTRIB_RELEASE}\"" 1.2740 + fi 1.2741 + ) 2>/dev/null` 1.2742 + fi 1.2743 + if [ ".$SP" = . ]; then 1.2744 + for tagfile in x \ 1.2745 + `cd /etc && \ 1.2746 + /bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \ 1.2747 + sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \ 1.2748 + echo redhat-release lsb-release` 1.2749 + do 1.2750 + [ ".${tagfile}" = .x ] && continue 1.2751 + [ ! -f "/etc/${tagfile}" ] && continue 1.2752 + n=`echo ${tagfile} | sed -e 's/[_-]release$//' -e 's/[_-]version$//'` 1.2753 + v=`(grep VERSION /etc/${tagfile}; cat /etc/${tagfile}) | grep '[0-9]' | sed -e 'q' |\ 1.2754 + sed -e 's/^/#/' \ 1.2755 + -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \ 1.2756 + -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \ 1.2757 + -e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \ 1.2758 + -e 's/^#.*$//'` 1.2759 + case "`util_lower ${n}`" in 1.2760 + redhat ) 1.2761 + if [ ".`egrep '(Red Hat Enterprise Linux|CentOS)' /etc/${tagfile}`" != . ]; then 1.2762 + n="<R>ed <H>at <E>nterprise <L>inux" 1.2763 + else 1.2764 + n="<R>ed <H>at <L>inux" 1.2765 + fi 1.2766 + ;; 1.2767 + debian ) n="Debian[ GNU/Linux]" ;; 1.2768 + ubuntu ) n="Ubuntu[ GNU/Linux]" ;; 1.2769 + fedora ) n="<Fedora> Core[ GNU/Linux]" ;; 1.2770 + suse ) n="[Novell ]SUSE[ Linux]" ;; 1.2771 + mandrake*|mandriva ) n="Mandriva[ Linux]" ;; 1.2772 + gentoo ) n="Gentoo[ GNU/Linux]" ;; 1.2773 + slackware ) n="Slackware[ Linux]" ;; 1.2774 + turbolinux ) n="TurboLinux" ;; 1.2775 + unitedlinux ) n="UnitedLinux" ;; 1.2776 + * ) n="${n}[ GNU/Linux]" ;; 1.2777 + esac 1.2778 + case "$n" in 1.2779 + *"<"*">"* ) SP="$n <$v>" ;; 1.2780 + * ) SP="$n $v" ;; 1.2781 + esac 1.2782 + break 1.2783 + done 1.2784 + fi 1.2785 + [ ".$SP" = . ] && SP="${ST}" 1.2786 + [ ".$SC" = . ] && SC="LSB" 1.2787 + ;; 1.2788 + 1.2789 + # Sun Solaris 1.2790 + *:SunOS:* ) 1.2791 + # determine architecture 1.2792 + AT="${UNAME_MACHINE}" 1.2793 + case "${AT}" in 1.2794 + i86pc ) 1.2795 + AT="iX86" 1.2796 + case "`(/bin/isainfo -k) 2>&1`" in 1.2797 + amd64 ) AT="AMD64" ;; 1.2798 + esac 1.2799 + ;; 1.2800 + esac 1.2801 + AP="${AT}" 1.2802 + case "${AP}" in 1.2803 + sun4[cdm] ) AP="SPARC32" ;; 1.2804 + sun4[uv] ) AP="SPARC64" ;; 1.2805 + sun4* ) AP="SPARC" ;; 1.2806 + esac 1.2807 + AC="${AP}" 1.2808 + case "${AC}" in 1.2809 + SPARC* ) AC="SPARC" ;; 1.2810 + esac 1.2811 + # determine system 1.2812 + ST="[Sun ]SunOS ${UNAME_RELEASE}" 1.2813 + v=`echo "${UNAME_RELEASE}" |\ 1.2814 + sed -e 's;^4\.;1.;' \ 1.2815 + -e 's;^5\.\([0-6]\)[^0-9]*$;2.\1;' \ 1.2816 + -e 's;^5\.\([0-9][0-9]*\).*;\1;'` 1.2817 + SP="[Sun ]Solaris $v" 1.2818 + case "${UNAME_RELEASE}" in 1.2819 + 4.* ) SC="4.3BSD" ;; 1.2820 + 5.* ) SC="SVR4" ;; 1.2821 + esac 1.2822 + ;; 1.2823 + 1.2824 + # SCO UnixWare 1.2825 + *:UnixWare:* ) 1.2826 + # determine architecture 1.2827 + AT="${UNAME_MACHINE}" 1.2828 + case "${AT}" in 1.2829 + i[3-6]86 | ix86at ) AT="iX86" ;; 1.2830 + esac 1.2831 + AP="${AT}" 1.2832 + # determine system 1.2833 + v=`/sbin/uname -v` 1.2834 + ST="[SCO ]UnixWare ${v}" 1.2835 + SP="${ST}" 1.2836 + SC="SVR${UNAME_RELEASE}" 1.2837 + ;; 1.2838 + 1.2839 + # QNX 1.2840 + *:QNX:* ) 1.2841 + # determine architecture 1.2842 + AT="${UNAME_MACHINE}" 1.2843 + case "${AT}" in 1.2844 + x86pc ) AT="iX86" ;; 1.2845 + esac 1.2846 + AP="${AT}" 1.2847 + # determine system 1.2848 + v="${UNAME_RELEASE}" 1.2849 + ST="QNX[ Neutrino RTOS] ${v}" 1.2850 + v=`echo "${v}" | sed -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\).*$;\1;'` 1.2851 + SP="QNX[ Neutrino RTOS] ${v}" 1.2852 + SC="QNX" 1.2853 + ;; 1.2854 + 1.2855 + # SGI IRIX 1.2856 + *:IRIX*:* ) 1.2857 + # determine architecture 1.2858 + AT="${UNAME_MACHINE}" 1.2859 + AP="${AT}" 1.2860 + case "${AP}:${UNAME_SYSTEM}" in 1.2861 + IP*:IRIX64 ) AP="MIPS64" ;; 1.2862 + IP*:* ) AP="MIPS" ;; 1.2863 + esac 1.2864 + AC="${AP}" 1.2865 + # determine system 1.2866 + v=`(/bin/uname -R || /bin/uname -r) 2>/dev/null | sed -e 's;[0-9.]* ;;'` 1.2867 + ST="[SGI ]IRIX ${v}" 1.2868 + v="${UNAME_RELEASE}" 1.2869 + SP="[SGI ]IRIX ${v}" 1.2870 + SC="4.2BSD/SVR3" 1.2871 + ;; 1.2872 + 1.2873 + # HP HP-UX 1.2874 + *:HP-UX:* ) 1.2875 + # determine architecture 1.2876 + AT="${UNAME_MACHINE}" 1.2877 + case "${AT}" in 1.2878 + ia64 ) AT="IA64" ;; 1.2879 + 9000/[34]?? ) AT=M68K ;; 1.2880 + 9000/[678][0-9][0-9]) 1.2881 + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` 1.2882 + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 1.2883 + case "${sc_cpu_version}" in 1.2884 + 523 ) AT="HPPA1.0" ;; 1.2885 + 528 ) AT="HPPA1.1" ;; 1.2886 + 532 ) AT="HPPA2.0" 1.2887 + case "${sc_kernel_bits}" in 1.2888 + 32 ) AT="${AT}n" ;; 1.2889 + 64 ) AT="${AT}w" ;; 1.2890 + esac 1.2891 + ;; 1.2892 + esac 1.2893 + ;; 1.2894 + esac 1.2895 + AP="${AT}" 1.2896 + case "${AP}" in 1.2897 + HPPA* ) AP="HPPA" ;; 1.2898 + esac 1.2899 + AC="${AP}" 1.2900 + # determine system 1.2901 + v=`echo "${UNAME_RELEASE}" | sed -e 's;^[^0-9]*;;'` 1.2902 + ST="[HP ]<HP>-<UX ${v}>" 1.2903 + SP="${ST}" 1.2904 + case "${v}" in 1.2905 + 10.* ) SC="SVR4.2" ;; 1.2906 + [7-9]* ) SC="SVR4" ;; 1.2907 + esac 1.2908 + ;; 1.2909 + 1.2910 + # HP Tru64 (OSF1) 1.2911 + *:OSF1:* ) 1.2912 + # determine architecture 1.2913 + AP="${UNAME_MACHINE}" 1.2914 + case "${AP}" in 1.2915 + alpha ) AP="Alpha" ;; 1.2916 + esac 1.2917 + alpha_type=`(/usr/sbin/psrinfo -v) 2>/dev/null |\ 1.2918 + sed -n -e 's/^.*The alpha \([^ ][^ ]*\).*processor.*$/\1/p' | sed -e 'q'` 1.2919 + AT="${AP}${alpha_type}" 1.2920 + AC="${AP}" 1.2921 + # determine system 1.2922 + v=`echo "${UNAME_RELEASE}" | sed -e 's;^[VTX];;'` 1.2923 + ST="[HP ]Tru64 ${v}" 1.2924 + SP="${ST}" 1.2925 + SC="OSF1" 1.2926 + ;; 1.2927 + 1.2928 + # IBM AIX 1.2929 + *:AIX:* ) 1.2930 + # determine architecture 1.2931 + cpu_arch=rs6000 1.2932 + if [ -x /usr/sbin/lsdev -a -x /usr/sbin/lsattr ]; then 1.2933 + cpu_id=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 1.2934 + if [ ".`/usr/sbin/lsattr -El ${cpu_id} | grep -i powerpc`" != . ]; then 1.2935 + cpu_arch=powerpc 1.2936 + fi 1.2937 + elif [ -d /QOpenSys ]; then 1.2938 + # IBM i5/OS (aka OS/400) with PASE (Portable Application Solutions Environment) 1.2939 + cpu_arch=powerpc 1.2940 + fi 1.2941 + if [ -x /usr/bin/oslevel ]; then 1.2942 + os_level=`/usr/bin/oslevel` 1.2943 + else 1.2944 + os_level="`uname -v`.`uname -r`" 1.2945 + fi 1.2946 + os_level=`echo "${os_level}" |\ 1.2947 + sed -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\)\(.*\)$;<\1>\2[\3];' \ 1.2948 + -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\)\(.*\)$;<\1>\2;'` 1.2949 + AT="${cpu_arch}" 1.2950 + AP="${AT}" 1.2951 + AC="${AP}" 1.2952 + # determine system 1.2953 + ST="[IBM ]<AIX >${os_level}" 1.2954 + SP="${ST}" 1.2955 + case "${os_level}" in 1.2956 + [12]* ) SC="SVR2" ;; 1.2957 + * ) SC="SVR4" ;; 1.2958 + esac 1.2959 + ;; 1.2960 + 1.2961 + # Apple Mac OS X (Darwin) 1.2962 + *:Darwin:* ) 1.2963 + # determine architecture 1.2964 + AT="`uname -p`" 1.2965 + case "${AT}" in 1.2966 + powerpc ) AT="PPC" ;; 1.2967 + esac 1.2968 + AP="${AT}" 1.2969 + case "${AP}" in 1.2970 + i?86 ) AP="iX86" ;; 1.2971 + esac 1.2972 + AC="${AP}" 1.2973 + # determine system 1.2974 + unset v1; unset v2; unset v3 1.2975 + eval `echo "${UNAME_RELEASE}" |\ 1.2976 + sed -e 's/^/#/' \ 1.2977 + -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"; v3="\3"/' \ 1.2978 + -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"/' \ 1.2979 + -e 's/^#\([0-9][0-9]*\).*$/v1="\1"/' \ 1.2980 + -e 's/^#.*$/v1="0"/'` 1.2981 + ST="[Apple ]<${UNAME_SYSTEM} ${v1}>${v2+.$v2}${v3+[.$v3]}" 1.2982 + SP="$ST" 1.2983 + v="`(sw_vers) 2>/dev/null | grep 'ProductVersion:' | sed -e 's/^ProductVersion:[^0-9]*\([0-9][0-9.]*\).*$/\1/'`" 1.2984 + if [ ".$v" = . ]; then 1.2985 + for name in System Server; do 1.2986 + if [ -f /System/Library/CoreServices/${name}Version.plist ]; then 1.2987 + v=`(defaults read "/System/Library/CoreServices/${name}Version" "ProductVersion") 2>/dev/null` 1.2988 + [ ".$v" != . ] && break 1.2989 + fi 1.2990 + done 1.2991 + fi 1.2992 + if [ ".$v" != . ]; then 1.2993 + unset v1; unset v2; unset v3 1.2994 + eval `echo "${v}" |\ 1.2995 + sed -e 's/^/#/' \ 1.2996 + -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"; v3="\3"/' \ 1.2997 + -e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"/' \ 1.2998 + -e 's/^#\([0-9][0-9]*\).*$/v1="\1"/' \ 1.2999 + -e 's/^#.*$/v1="0"/'` 1.3000 + SP="[Apple ]Mac OS X ${v1}${v2+.$v2}${v3+[.$v3]}" 1.3001 + fi 1.3002 + SC="4.4BSD/Mach3.0" 1.3003 + ;; 1.3004 + 1.3005 + # TODO ...ADD YOUR NEW PLATFORM CHECK HERE... TODO 1.3006 + # *:XXX:* ) 1.3007 + # ... 1.3008 + # ;; 1.3009 + 1.3010 + # ...A STILL UNKNOWN PLATFORM... 1.3011 + * ) 1.3012 + AT=`echo "${UNAME_MACHINE}" | sed -e "s; ;${opt_C};g"` 1.3013 + AP="${AT}" 1.3014 + AC="${AP}" 1.3015 + v=`echo "${UNAME_RELEASE}" |\ 1.3016 + sed -e 's/^/#/' \ 1.3017 + -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \ 1.3018 + -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \ 1.3019 + -e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \ 1.3020 + -e 's/^#.*$/?/'` 1.3021 + ST="${UNAME_SYSTEM} ${v}" 1.3022 + SP="${ST}" 1.3023 + SC="${SP}" 1.3024 + ;; 1.3025 + 1.3026 + esac 1.3027 + 1.3028 + # provide fallback values 1.3029 + [ ".$AT" = . ] && AT="${AP:-${AC}}" 1.3030 + [ ".$AP" = . ] && AP="${AT:-${AC}}" 1.3031 + [ ".$AC" = . ] && AC="${AP:-${AT}}" 1.3032 + [ ".$ST" = . ] && ST="${SP:-${SC}}" 1.3033 + [ ".$SP" = . ] && SP="${ST:-${SC}}" 1.3034 + [ ".$SC" = . ] && SC="${SP:-${ST}}" 1.3035 + 1.3036 + # support explicit enforced verbose/concise output 1.3037 + if [ ".$opt_v" = .yes ]; then 1.3038 + opt_F=`echo ":$opt_F" | sed -e 's/^://' -e 's/%\([as][cpt]\)/%[\1]/g'` 1.3039 + elif [ ".$opt_c" = .yes ]; then 1.3040 + opt_F=`echo ":$opt_F" | sed -e 's/^://' -e 's/%\([as][cpt]\)/%<\1>/g'` 1.3041 + fi 1.3042 + 1.3043 + # provide verbose and concise variants 1.3044 + AC_V=""; AC_N=""; AC_C="" 1.3045 + AP_V=""; AP_N=""; AP_C="" 1.3046 + AT_V=""; AT_N=""; AT_C="" 1.3047 + SC_V=""; SC_N=""; SC_C="" 1.3048 + SP_V=""; SP_N=""; SP_C="" 1.3049 + ST_V=""; ST_N=""; ST_C="" 1.3050 + for var_lc in at ap ac st sp sc; do 1.3051 + case "$opt_F" in 1.3052 + *"%[${val_lc}]"* | *"%{${val_lc}}"* | *"%${val_lc}"* | *"%<${val_lc}>"* ) 1.3053 + var_uc=`util_upper "$var_lc"` 1.3054 + eval "val=\"\$${var_uc}\"" 1.3055 + val_V=""; val_N=""; val_C="" 1.3056 + case "$opt_F" in 1.3057 + *"%[${var_lc}]"* ) 1.3058 + val_V=`echo ":$val" | \ 1.3059 + sed -e 's/^://' \ 1.3060 + -e 's;\[\([^]]*\)\];\1;g' \ 1.3061 + -e 's;<\([^>]*\)>;\1;g' \ 1.3062 + -e "s; ;§§;g" \ 1.3063 + -e "s;/;%%;g" \ 1.3064 + -e "s;§§;${opt_S};g" \ 1.3065 + -e "s;%%;${opt_C};g"` 1.3066 + eval "${var_uc}_V=\"\${val_V}\"" 1.3067 + ;; 1.3068 + esac 1.3069 + case "$opt_F" in 1.3070 + *"%{${var_lc}}"* | *"%${var_lc}"* ) 1.3071 + val_N=`echo ":$val" | \ 1.3072 + sed -e 's/^://' \ 1.3073 + -e 's;\[\([^]]*\)\];;g' \ 1.3074 + -e 's;<\([^>]*\)>;\1;g' \ 1.3075 + -e "s; ;§§;g" \ 1.3076 + -e "s;/;%%;g" \ 1.3077 + -e "s;§§;${opt_S};g" \ 1.3078 + -e "s;%%;${opt_C};g"` 1.3079 + eval "${var_uc}_N=\"\${val_N}\"" 1.3080 + ;; 1.3081 + esac 1.3082 + case "$opt_F" in 1.3083 + *"%<${var_lc}>"* ) 1.3084 + val_C=`echo ":$val" | \ 1.3085 + sed -e 's/^://' \ 1.3086 + -e 's;\[\([^]]*\)\];;g' \ 1.3087 + -e 's;[^<]*<\([^>]*\)>[^<]*;\1;g' \ 1.3088 + -e "s; ;§§;g" \ 1.3089 + -e "s;/;%%;g" \ 1.3090 + -e "s;§§;${opt_S};g" \ 1.3091 + -e "s;%%;${opt_C};g"` 1.3092 + eval "${var_uc}_C=\"\${val_C}\"" 1.3093 + ;; 1.3094 + esac 1.3095 + ;; 1.3096 + esac 1.3097 + done 1.3098 + 1.3099 + # create output string 1.3100 + output=`echo ":$opt_F" |\ 1.3101 + sed -e "s/^://" \ 1.3102 + -e "s;%\\[ac\\];${AC_V};g" \ 1.3103 + -e "s;%{ac};${AC_N};g" \ 1.3104 + -e "s;%ac;${AC_N};g" \ 1.3105 + -e "s;%<ac>;${AC_C};g" \ 1.3106 + -e "s;%\\[ap\\];${AP_V};g" \ 1.3107 + -e "s;%{ap};${AP_N};g" \ 1.3108 + -e "s;%ap;${AP_N};g" \ 1.3109 + -e "s;%<ap>;${AP_C};g" \ 1.3110 + -e "s;%\\[at\\];${AT_V};g" \ 1.3111 + -e "s;%{at};${AT_N};g" \ 1.3112 + -e "s;%at;${AT_N};g" \ 1.3113 + -e "s;%<at>;${AT_C};g" \ 1.3114 + -e "s;%\\[sc\\];${SC_V};g" \ 1.3115 + -e "s;%{sc};${SC_N};g" \ 1.3116 + -e "s;%sc;${SC_N};g" \ 1.3117 + -e "s;%<sc>;${SC_C};g" \ 1.3118 + -e "s;%\\[sp\\];${SP_V};g" \ 1.3119 + -e "s;%{sp};${SP_N};g" \ 1.3120 + -e "s;%sp;${SP_N};g" \ 1.3121 + -e "s;%<sp>;${SP_C};g" \ 1.3122 + -e "s;%\\[st\\];${ST_V};g" \ 1.3123 + -e "s;%{st};${ST_N};g" \ 1.3124 + -e "s;%st;${ST_N};g" \ 1.3125 + -e "s;%<st>;${ST_C};g" \ 1.3126 + -e 's/\\\\n/^/g' |\ 1.3127 + tr '^' '\012'` 1.3128 + 1.3129 + # support lower/upper-case mapping 1.3130 + if [ ".$opt_L" = .yes ]; then 1.3131 + output=`util_lower "$output"` 1.3132 + elif [ ".$opt_U" = .yes ]; then 1.3133 + output=`util_upper "$output"` 1.3134 + fi 1.3135 + 1.3136 + # display output string 1.3137 + if [ ".$opt_n" = .yes ]; then 1.3138 + echo . | awk '{ printf("%s", output); }' output="$output" 1.3139 + else 1.3140 + echo "$output" 1.3141 + fi 1.3142 + 1.3143 + shtool_exit 0 1.3144 + ;; 1.3145 + 1.3146 +arx ) 1.3147 + ## 1.3148 + ## arx -- Extended archive command 1.3149 + ## Copyright (c) 1999-2007 Ralf S. Engelschall <rse@engelschall.com> 1.3150 + ## 1.3151 + 1.3152 + ar_prg="$opt_C" 1.3153 + ar_cmd="$1"; shift 1.3154 + archive="$1"; shift 1.3155 + files="$*" 1.3156 + 1.3157 + # walk through the file list and expand archives members 1.3158 + ar_tmpdir=`echo $archive | sed -e 's;[^/]*$;.arx;'` 1.3159 + nfiles='' 1.3160 + if [ ".$files" != . ]; then 1.3161 + for file in $files; do 1.3162 + if [ ! -f $file ]; then 1.3163 + echo "$msgprefix:Error: input file not found: $file" 1>&2 1.3164 + shtool_exit 1 1.3165 + fi 1.3166 + case $file in 1.3167 + *.a ) 1.3168 + if [ ! -d $ar_tmpdir ]; then 1.3169 + if [ ".$opt_t" = .yes ]; then 1.3170 + echo "mkdir $ar_tmpdir" 1>&2 1.3171 + fi 1.3172 + mkdir $ar_tmpdir 1.3173 + fi 1.3174 + case $ar_tmpdir in 1.3175 + .arx ) 1.3176 + from="../$file" 1.3177 + ;; 1.3178 + * ) 1.3179 + dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;'` 1.3180 + base=`echo $file | sed -e 's;.*/\([^/]*\)$;\1;'` 1.3181 + from="`cd $dir; pwd`/$base" 1.3182 + ;; 1.3183 + esac 1.3184 + if [ ".$opt_t" = .yes ]; then 1.3185 + echo "(cd $ar_tmpdir && $ar_prg x $from)" 1>&2 1.3186 + fi 1.3187 + (cd $ar_tmpdir && eval $ar_prg x $from) 1.3188 + if [ $? -ne 0 ]; then 1.3189 + echo "$msgprefix:Error: member extraction failed for archive: $file" 1>&2 1.3190 + shtool_exit 1 1.3191 + fi 1.3192 + for member in - `eval $ar_prg t $file | sed -e '/_\.SYMDEF/d'`; do 1.3193 + [ ".$member" = .- ] && continue 1.3194 + nfiles="$nfiles $ar_tmpdir/$member" 1.3195 + done 1.3196 + ;; 1.3197 + * ) 1.3198 + nfiles="$nfiles $file" 1.3199 + ;; 1.3200 + esac 1.3201 + done 1.3202 + fi 1.3203 + 1.3204 + # run the final archive command 1.3205 + if [ ".$opt_t" = .yes ]; then 1.3206 + echo "$ar_prg $ar_cmd $archive $nfiles" 1>&2 1.3207 + fi 1.3208 + eval $ar_prg $ar_cmd $archive $nfiles 1.3209 + if [ $? -ne 0 ]; then 1.3210 + echo "$msgprefix:Error: archive command failed" 1>&2 1.3211 + shtool_exit $? 1.3212 + fi 1.3213 + 1.3214 + # cleanup and die gracefully 1.3215 + if [ -d $ar_tmpdir ]; then 1.3216 + if [ ".$opt_t" = .yes ]; then 1.3217 + echo "rm -rf $ar_tmpdir" 1>&2 1.3218 + fi 1.3219 + rm -rf $ar_tmpdir 1.3220 + fi 1.3221 + 1.3222 + shtool_exit 0 1.3223 + ;; 1.3224 + 1.3225 +slo ) 1.3226 + ## 1.3227 + ## slo -- Separate linker options by library class 1.3228 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.3229 + ## 1.3230 + 1.3231 + DIFS="$IFS" 1.3232 + 1.3233 + # parse out -L and -l options from command line 1.3234 + DIRS='' 1.3235 + LIBS='' 1.3236 + ARGV='' 1.3237 + optprev='' 1.3238 + for opt 1.3239 + do 1.3240 + # concatenate with previous option if exists 1.3241 + if [ ".$optprev" != . ]; then 1.3242 + opt="${optprev}${opt}"; 1.3243 + optprev='' 1.3244 + fi 1.3245 + # remember options for arg if used stand-alone 1.3246 + if [ ".$opt" = ".-L" ] || [ ".$opt" = ".-l" ]; then 1.3247 + optprev="$opt" 1.3248 + continue; 1.3249 + fi 1.3250 + # split argument into option plus option argument 1.3251 + arg="`echo $opt | cut -c3-`" 1.3252 + opt="`echo $opt | cut -c1-2`" 1.3253 + # store into containers 1.3254 + case $opt in 1.3255 + -L) DIRS="$DIRS:$arg" ;; 1.3256 + -l) LIBS="$LIBS:$arg" ;; 1.3257 + *) ARGV="$ARGV $opt" ;; 1.3258 + esac 1.3259 + done 1.3260 + 1.3261 + # set linker default directories 1.3262 + DIRS_DEFAULT='/lib:/usr/lib' 1.3263 + if [ ".$LD_LIBRARY_PATH" != . ]; then 1.3264 + DIRS_DEFAULT="$DIRS_DEFAULT:$LD_LIBRARY_PATH" 1.3265 + fi 1.3266 + 1.3267 + # sort options by class 1.3268 + DIRS_OBJ='' 1.3269 + LIBS_OBJ='' 1.3270 + DIRS_PIC='' 1.3271 + LIBS_PIC='' 1.3272 + DIRS_DSO='' 1.3273 + LIBS_DSO='' 1.3274 + 1.3275 + # for each library... 1.3276 + OIFS="$IFS"; IFS=':' 1.3277 + for lib in $LIBS; do 1.3278 + [ ".$lib" = . ] && continue 1.3279 + 1.3280 + found='no' 1.3281 + found_indefdir='no' 1.3282 + found_type='' 1.3283 + found_dir='' 1.3284 + 1.3285 + # for each directory... 1.3286 + OIFS2="$IFS"; IFS=":$DIFS" 1.3287 + for dir in ${DIRS} switch-to-defdirs ${DIRS_DEFAULT}; do 1.3288 + [ ".$dir" = . ] && continue 1.3289 + [ ".$dir" = .switch-to-defdirs ] && found_indefdir=yes 1.3290 + [ ! -d $dir ] && continue 1.3291 + 1.3292 + # search the file 1.3293 + OIFS3="$IFS"; IFS="$DIFS" 1.3294 + for file in '' `cd $dir && env -i /bin/ls lib${lib}.* 2>/dev/null`; do 1.3295 + [ ".$file" = . ] && continue 1.3296 + case $file in 1.3297 + *.so|*.so.[0-9]*|*.sl|*.sl.[0-9]* ) 1.3298 + found=yes; 1.3299 + found_type=DSO; 1.3300 + break 1.3301 + ;; 1.3302 + *.lo|*.la ) 1.3303 + found=yes; 1.3304 + found_type=PIC 1.3305 + ;; 1.3306 + *.a ) 1.3307 + if [ ".$found_type" = . ]; then 1.3308 + found=yes 1.3309 + found_type=OBJ 1.3310 + fi 1.3311 + ;; 1.3312 + esac 1.3313 + done 1.3314 + IFS="$OIFS3" 1.3315 + if [ ".$found" = .yes ]; then 1.3316 + found_dir="$dir" 1.3317 + break 1.3318 + fi 1.3319 + done 1.3320 + IFS="$OIFS2" 1.3321 + 1.3322 + if [ ".$found" = .yes ]; then 1.3323 + if [ ".$found_indefdir" != .yes ]; then 1.3324 + eval "dirlist=\"\${DIRS_${found_type}}:\"" 1.3325 + case "$dirlist" in 1.3326 + *:$found_dir:* ) ;; 1.3327 + * ) eval "DIRS_${found_type}=\"\$DIRS_${found_type}:${found_dir}\"" ;; 1.3328 + esac 1.3329 + eval "LIBS_${found_type}=\"\$LIBS_${found_type}:$lib\"" 1.3330 + else 1.3331 + eval "LIBS_${found_type}=\"\$LIBS_${found_type}:$lib\"" 1.3332 + fi 1.3333 + else 1.3334 + LIBS_OBJ="$LIBS_OBJ:$lib" 1.3335 + #dirlist="`echo $DIRS $DIRS_DEFAULT | sed -e 's/:/ /g'`" 1.3336 + #echo "slo:Warning: library \"$lib\" not found in any of the following dirs:" 2>&1 1.3337 + #echo "slo:Warning: $dirlist" 1>&1 1.3338 + fi 1.3339 + done 1.3340 + IFS="$OIFS" 1.3341 + 1.3342 + # also pass-through unused dirs even if it's useless 1.3343 + OIFS="$IFS"; IFS=':' 1.3344 + for dir in $DIRS; do 1.3345 + dirlist="${DIRS_OBJ}:${DIRS_PIC}:${DIRS_DSO}:" 1.3346 + case "$dirlist" in 1.3347 + *:$dir:* ) ;; 1.3348 + * ) DIRS_OBJ="$DIRS_OBJ:$dir" ;; 1.3349 + esac 1.3350 + done 1.3351 + IFS="$OIFS" 1.3352 + 1.3353 + # reassemble the options but separated by type 1.3354 + for type in OBJ PIC DSO; do 1.3355 + OIFS="$IFS"; IFS=':' 1.3356 + eval "libs=\"\$LIBS_${type}\"" 1.3357 + opts='' 1.3358 + for lib in $libs; do 1.3359 + [ ".$lib" = . ] && continue 1.3360 + opts="$opts -l$lib" 1.3361 + done 1.3362 + eval "LIBS_${type}=\"$opts\"" 1.3363 + 1.3364 + eval "dirs=\"\$DIRS_${type}\"" 1.3365 + opts='' 1.3366 + for dir in $dirs; do 1.3367 + [ ".$dir" = . ] && continue 1.3368 + opts="$opts -L$dir" 1.3369 + done 1.3370 + eval "DIRS_${type}=\"$opts\"" 1.3371 + IFS="$OIFS" 1.3372 + done 1.3373 + 1.3374 + # give back results 1.3375 + for var in ARGV DIRS_OBJ LIBS_OBJ DIRS_PIC LIBS_PIC DIRS_DSO LIBS_DSO; do 1.3376 + eval "val=\"\$${var}\"" 1.3377 + val="`echo $val | sed -e 's/^ *//'`" 1.3378 + echo "${opt_p}${var}=\"${val}\"" 1.3379 + done 1.3380 + 1.3381 + shtool_exit 0 1.3382 + ;; 1.3383 + 1.3384 +scpp ) 1.3385 + ## 1.3386 + ## scpp -- Sharing C Pre-Processor 1.3387 + ## Copyright (c) 1999-2007 Ralf S. Engelschall <rse@engelschall.com> 1.3388 + ## 1.3389 + 1.3390 + srcs="$*" 1.3391 + output="${opt_o}.n" 1.3392 + 1.3393 + # find a reasonable Awk 1.3394 + awk='' 1.3395 + paths=`echo $PATH |\ 1.3396 + sed -e 's%/*:%:%g' -e 's%/$%%' \ 1.3397 + -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \ 1.3398 + -e 's/:/ /g'` 1.3399 + for name in gawk nawk awk; do 1.3400 + for path in $paths; do 1.3401 + if [ -r "$path/$name" ]; then 1.3402 + awk="$path/$name" 1.3403 + break 1.3404 + fi 1.3405 + done 1.3406 + if [ ".$awk" != . ]; then 1.3407 + break 1.3408 + fi 1.3409 + done 1.3410 + if [ ".$awk" = . ]; then 1.3411 + echo "$msgprefix:Error: cannot find a reasonable Awk" 1>&2 1.3412 + shtool_exit 1 1.3413 + fi 1.3414 + 1.3415 + # parse source file(s) 1.3416 + if [ ".$opt_v" = .yes ]; then 1.3417 + echo "Parsing:" | $awk '{ printf("%s", $0); }' 1>&2 1.3418 + fi 1.3419 + for src in $srcs; do 1.3420 + if [ ".$opt_v" = .yes ]; then 1.3421 + echo $src | $awk '{ printf(" %s", $0); }' 1>&2 1.3422 + fi 1.3423 + if [ ".$opt_f" != . ]; then 1.3424 + inputcmd="sed" 1.3425 + OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_f; IFS="$OIFS" 1.3426 + for e 1.3427 + do 1.3428 + inputcmd="$inputcmd -e '$e'" 1.3429 + done 1.3430 + inputcmd="$inputcmd '$src'" 1.3431 + else 1.3432 + inputcmd="cat '$src'" 1.3433 + fi 1.3434 + eval $inputcmd |\ 1.3435 + $awk ' 1.3436 + BEGIN { 1.3437 + ln = 0; 1.3438 + fln = 0; 1.3439 + level = 0; 1.3440 + mode = ""; 1.3441 + store = ""; 1.3442 + } 1.3443 + { 1.3444 + ln++; 1.3445 + } 1.3446 + /^#if.*/ { 1.3447 + level++; 1.3448 + } 1.3449 + /^#if [a-zA-Z_][a-zA-Z0-9_]* *$/ { 1.3450 + if ($2 == define) { 1.3451 + mode = "D"; 1.3452 + printf("D:#line %d \"%s\"\n", ln, src); 1.3453 + next; 1.3454 + } 1.3455 + } 1.3456 + /^#endif.*/ { 1.3457 + level--; 1.3458 + if (mode == "D" && level == 0) { 1.3459 + mode = ""; 1.3460 + next; 1.3461 + } 1.3462 + } 1.3463 + /^[a-zA-Z_][a-zA-Z0-9_].*;.*/ { 1.3464 + if ($1 == class) { 1.3465 + printf("V:#line %d \"%s\"\n", ln, src); 1.3466 + printf("V:%s\n", $0); 1.3467 + printf("J:%s\n", $0); 1.3468 + next; 1.3469 + } 1.3470 + } 1.3471 + /^[a-zA-Z_][a-zA-Z0-9_].*=.*/ { 1.3472 + if ($1 == class) { 1.3473 + printf("V:#line %d \"%s\"\n", ln, src); 1.3474 + printf("V:%s\n", $0); 1.3475 + printf("J:%s\n", $0); 1.3476 + next; 1.3477 + } 1.3478 + } 1.3479 + /^[a-zA-Z_][a-zA-Z0-9_]*/ { 1.3480 + if ($1 == class) { 1.3481 + fln = ln; 1.3482 + store = $0; 1.3483 + mode = "F"; 1.3484 + next; 1.3485 + } 1.3486 + } 1.3487 + /^\{ *$/ { 1.3488 + if (mode == "F") { 1.3489 + printf("F:#line %d \"%s\"\n", fln, src); 1.3490 + printf("F:%s;\n", store); 1.3491 + printf("I:%s;\n", store); 1.3492 + store = ""; 1.3493 + mode = ""; 1.3494 + next; 1.3495 + } 1.3496 + } 1.3497 + { 1.3498 + if (mode == "D") 1.3499 + printf("D:%s\n", $0); 1.3500 + else if (mode == "F") 1.3501 + store = store " " $0; 1.3502 + } 1.3503 + ' "src=$src" "define=$opt_D" "class=$opt_C" >>$tmpfile 1.3504 + done 1.3505 + if [ ".$opt_v" = .yes ]; then 1.3506 + echo "" 1>&2 1.3507 + fi 1.3508 + 1.3509 + # start generating output header 1.3510 + echo "/* $opt_o -- autogenerated from $opt_t, DO NOT EDIT! */" >$output 1.3511 + echo "#line 1 \"$opt_t\"" >>$output 1.3512 + sed <$opt_t -e "1,/^${opt_M} *\$/p" -e 'd' |\ 1.3513 + sed -e "/^${opt_M} *\$/d" >>$output 1.3514 + 1.3515 + # merge in the define blocks 1.3516 + grep '^D:' $tmpfile | sed -e 's/^D://' >>$output 1.3517 + 1.3518 + # generate standard prolog 1.3519 + echo "#line 1 \"_ON_THE_FLY_\"" >>$output 1.3520 + echo "" >>$output 1.3521 + echo "/* make sure the scpp source extensions are skipped */" >>$output 1.3522 + echo "#define $opt_D 0" >>$output 1.3523 + echo "#define $opt_C /**/" >>$output 1.3524 + 1.3525 + # generate namespace hiding for variables 1.3526 + echo "" >>$output 1.3527 + echo "/* move intern variables to hidden namespace */" >>$output 1.3528 + grep '^J:' $tmpfile | sed >>$output \ 1.3529 + -e 's/^J://' \ 1.3530 + -e 's/ */ /g' \ 1.3531 + -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\)\[\];.*$/#define \1 __\1/' \ 1.3532 + -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\)\[\] =.*$/#define \1 __\1/' \ 1.3533 + -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\);.*$/#define \1 __\1/' \ 1.3534 + -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\) =.*$/#define \1 __\1/' 1.3535 + 1.3536 + # generate namespace hiding for functions 1.3537 + echo "" >>$output 1.3538 + echo "/* move intern functions to hidden namespace */" >>$output 1.3539 + grep '^I:' $tmpfile | sed >>$output \ 1.3540 + -e 's/^I://' \ 1.3541 + -e 's/\([ (]\) */\1/g' \ 1.3542 + -e 's/ *\([),]\)/\1/g' \ 1.3543 + -e 's/^[^(]*[ *]\([a-zA-Z0-9_]*\)(.*$/#define \1 __\1/' 1.3544 + 1.3545 + # generate prototypes for variables 1.3546 + echo "" >>$output 1.3547 + echo "/* prototypes for intern variables */" >>$output 1.3548 + grep '^V:' $tmpfile | sed >>$output \ 1.3549 + -e 's/^V://' \ 1.3550 + -e 's/ */ /g' \ 1.3551 + -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\[\]\);.*$/\1;/' \ 1.3552 + -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\[\]\) =.*$/\1;/' \ 1.3553 + -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\);.*$/\1;/' \ 1.3554 + -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\) =.*$/\1;/' \ 1.3555 + -e 's/ ;/;/g' \ 1.3556 + -e "s/^$opt_C /extern /" 1.3557 + 1.3558 + # generate prototypes for functions 1.3559 + echo "" >>$output 1.3560 + echo "/* prototypes for intern functions */" >>$output 1.3561 + grep '^F:' $tmpfile | sed >>$output \ 1.3562 + -e 's/^F://' \ 1.3563 + -e 's/\([ (]\) */\1/g' \ 1.3564 + -e 's/ *\([),]\)/\1/g' \ 1.3565 + -e 's/\([* ]\)[a-zA-Z0-9_]*,/\1,/g' \ 1.3566 + -e 's/\([* ]\)[a-zA-Z0-9_]*);/\1);/g' \ 1.3567 + -e 's/(\*[a-zA-Z0-9_]*)(/(*)(/g' \ 1.3568 + -e 's/\([ (]\) */\1/g' \ 1.3569 + -e 's/ *\([),]\)/\1/g' \ 1.3570 + -e "s/^$opt_C /extern /" 1.3571 + 1.3572 + # finish generating output header 1.3573 + n=`(echo ''; sed <$opt_t -e "1,/^${opt_M} *\$/p" -e 'd') |\ 1.3574 + wc -l | sed -e 's;^ *\([0-9]*\) *$;\1;'` 1.3575 + echo "#line $n \"$opt_t\"" >>$output 1.3576 + sed <$opt_t -e "/^${opt_M} *\$/,\$p" -e 'd' |\ 1.3577 + sed -e "/^${opt_M} *\$/d" >>$output 1.3578 + 1.3579 + # create final output file 1.3580 + if [ -f $opt_o ]; then 1.3581 + if [ ".$opt_p" = .yes ]; then 1.3582 + grep -v '^#line' $opt_o >$tmpfile.o 1.3583 + grep -v '^#line' $output >$tmpfile.n 1.3584 + out_old="$tmpfile.o" 1.3585 + out_new="$tmpfile.n" 1.3586 + else 1.3587 + out_old="$opt_o" 1.3588 + out_new="$output" 1.3589 + fi 1.3590 + if cmp -s $out_old $out_new; then 1.3591 + : 1.3592 + else 1.3593 + cp $output $opt_o 1.3594 + fi 1.3595 + else 1.3596 + cp $output $opt_o 1.3597 + fi 1.3598 + rm -f $output 1.3599 + rm -f $tmpfile $tmpfile.* >/dev/null 2>&1 1.3600 + 1.3601 + shtool_exit 0 1.3602 + ;; 1.3603 + 1.3604 +version ) 1.3605 + ## 1.3606 + ## version -- Maintain a version information file 1.3607 + ## Copyright (c) 1994-2007 Ralf S. Engelschall <rse@engelschall.com> 1.3608 + ## 1.3609 + 1.3610 + file="$1" 1.3611 + 1.3612 + # determine prefix and name 1.3613 + name="$opt_n" 1.3614 + prefix="$opt_p" 1.3615 + 1.3616 + # determine current version 1.3617 + triple="$opt_s" 1.3618 + if [ ".$triple" != . ]; then 1.3619 + # use given triple 1.3620 + if [ ".`echo $triple | grep '[0-9]*.[0-9]*[sabp.][0-9]*'`" = . ]; then 1.3621 + echo "$msgprefix:Error: invalid argument to option \`-s': \`$opt_s'" 1>&2 1.3622 + shtool_exit 1 1.3623 + fi 1.3624 + eval `echo $triple |\ 1.3625 + sed -e 's%\([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\).*%\ 1.3626 + ver="\1";rev="\2";typ="\3";lev="\4"%'` 1.3627 + tim=calc 1.3628 + elif [ -r $file ]; then 1.3629 + # determine triple from given file 1.3630 + eval `grep 'Version [0-9]*.[0-9]*[sabp.][0-9]* ([0-9]*-[a-zA-Z]*-[0-9]*)' $file |\ 1.3631 + sed -e 's%.*Version \([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\) (\([0-9]*-[a-zA-Z]*-[0-9]*\)).*%\ 1.3632 + ver="\1";rev="\2";typ="\3";lev="\4";tim="\5"%' -e 'q'` 1.3633 + else 1.3634 + # intialise to first version 1.3635 + ver=0 1.3636 + rev=1 1.3637 + typ=. 1.3638 + lev=0 1.3639 + tim=calc 1.3640 + fi 1.3641 + 1.3642 + # determine new version in batch 1.3643 + if [ ".$opt_i" != . ]; then 1.3644 + case $opt_i in 1.3645 + v ) ver=`expr $ver + 1` 1.3646 + rev=0 1.3647 + lev=0 1.3648 + ;; 1.3649 + r ) rev=`expr $rev + 1` 1.3650 + lev=0 1.3651 + ;; 1.3652 + l ) lev=`expr $lev + 1` 1.3653 + ;; 1.3654 + * ) echo "$msgprefix:Error: invalid argument to option \`-i': \`$opt_i'" 1>&2 1.3655 + shtool_exit 1 1.3656 + ;; 1.3657 + esac 1.3658 + tim=calc 1.3659 + fi 1.3660 + 1.3661 + # determine new version interactively 1.3662 + if [ ".$opt_e" = .yes ]; then 1.3663 + echo "old version: ${ver}.${rev}${typ}${lev}" 1.3664 + while [ 1 ]; do 1.3665 + echo dummy | awk '{ printf("new version: "); }' 1.3666 + read triple 1.3667 + case $triple in 1.3668 + [0-9]*.[0-9]*[sabp.][0-9]* ) 1.3669 + ;; 1.3670 + * ) echo "$msgprefix:Error: invalid version string entered: \`$triple'" 1>&2 1.3671 + continue 1.3672 + ;; 1.3673 + esac 1.3674 + break 1.3675 + done 1.3676 + eval `echo $triple |\ 1.3677 + sed -e 's%^\([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\)$%\ 1.3678 + ver="\1";rev="\2";typ="\3";lev="\4"%'` 1.3679 + tim=calc 1.3680 + fi 1.3681 + 1.3682 + # determine hexadecimal and libtool value of version 1.3683 + case $typ in 1.3684 + a ) typnum=0; levnum=$lev ;; 1.3685 + b ) typnum=1; levnum=$lev ;; 1.3686 + p | . ) typnum=2; levnum=$lev ;; 1.3687 + s ) typnum=15; levnum=255 ;; # snapshots are special 1.3688 + esac 1.3689 + hex=`echo "$ver:$rev:$typnum:$levnum" |\ 1.3690 + awk -F: '{ printf("0x%x%02x%1x%02x", $1, $2, $3, $4); }' |\ 1.3691 + tr 'abcdef' 'ABCDEF'` 1.3692 + ltv=`echo "$ver:$rev:$typnum:$levnum" |\ 1.3693 + awk -F: '{ printf("%d:%d", $1*10 + $2, $3*10 + $4); }'` 1.3694 + 1.3695 + # determine date 1.3696 + if [ ".$tim" = .calc ]; then 1.3697 + day=`date '+%d'` 1.3698 + month=`date '+%m'` 1.3699 + year=`date '+%Y' 2>/dev/null` 1.3700 + if [ ".$time_year" = . ]; then 1.3701 + year=`date '+%y'` 1.3702 + case $year in 1.3703 + [5-9][0-9]) year="19$year" ;; 1.3704 + [0-4][0-9]) year="20$year" ;; 1.3705 + esac 1.3706 + fi 1.3707 + case $month in 1.3708 + 1|01) month='Jan' ;; 1.3709 + 2|02) month='Feb' ;; 1.3710 + 3|03) month='Mar' ;; 1.3711 + 4|04) month='Apr' ;; 1.3712 + 5|05) month='May' ;; 1.3713 + 6|06) month='Jun' ;; 1.3714 + 7|07) month='Jul' ;; 1.3715 + 8|08) month='Aug' ;; 1.3716 + 9|09) month='Sep' ;; 1.3717 + 10) month='Oct' ;; 1.3718 + 11) month='Nov' ;; 1.3719 + 12) month='Dec' ;; 1.3720 + esac 1.3721 + tim="${day}-${month}-${year}" 1.3722 + fi 1.3723 + 1.3724 + # perform result actions 1.3725 + mode=show 1.3726 + if [ ".$opt_i" != . ]; then 1.3727 + mode=edit 1.3728 + elif [ ".$opt_e" = .yes ]; then 1.3729 + mode=edit 1.3730 + elif [ ".$opt_s" != . ]; then 1.3731 + mode=edit 1.3732 + fi 1.3733 + if [ ".$mode" = .show ]; then 1.3734 + # just display the current version 1.3735 + case $opt_d in 1.3736 + short ) 1.3737 + echo "${ver}.${rev}${typ}${lev}" 1.3738 + ;; 1.3739 + long ) 1.3740 + echo "${ver}.${rev}${typ}${lev} ($tim)" 1.3741 + ;; 1.3742 + libtool ) 1.3743 + echo "${ltv}" 1.3744 + ;; 1.3745 + hex ) 1.3746 + echo "${hex}" 1.3747 + ;; 1.3748 + * ) echo "$msgprefix:Error: invalid argument to option \`-d': \`$opt_d'" 1>&2 1.3749 + shtool_exit 1 1.3750 + ;; 1.3751 + esac 1.3752 + else 1.3753 + # update the version file 1.3754 + 1.3755 + # pre-generate various strings 1.3756 + triple="${ver}.${rev}${typ}${lev}" 1.3757 + vHex="$hex" 1.3758 + vShort="${triple}" 1.3759 + vLong="${triple} (${tim})" 1.3760 + vTeX="This is ${name}, Version ${triple} (${tim})" 1.3761 + vGNU="${name} ${triple} (${tim})" 1.3762 + vWeb="${name}/${triple}" 1.3763 + vSCCS="@(#)${name} ${triple} (${tim})" 1.3764 + vRCS="\$Id: ${name} ${triple} (${tim}) \$" 1.3765 + 1.3766 + # determine string out of filename 1.3767 + # (do NOT try to optimize this in any way because of portability) 1.3768 + filestr=`util_upper "$file" | tr './%+' '____' | sed -e 's/-/_/g'` 1.3769 + 1.3770 + # generate uppercase prefix 1.3771 + prefixupper=`util_upper "$prefix"` 1.3772 + 1.3773 + # create the version file according the the selected language 1.3774 + echo "new version: ${vLong}" 1.3775 + 1.3776 + cp /dev/null $file 1.3777 + case $opt_l in 1.3778 + txt ) 1.3779 + echo >>$file "" 1.3780 + echo >>$file " ${file} -- Version Information for ${name} (syntax: Text)" 1.3781 + echo >>$file " [automatically generated and maintained by GNU shtool]" 1.3782 + echo >>$file "" 1.3783 + echo >>$file " $vTeX" 1.3784 + echo >>$file "" 1.3785 + ;; 1.3786 + c ) 1.3787 + echo >>$file "/*" 1.3788 + echo >>$file "** ${file} -- Version Information for ${name} (syntax: C/C++)" 1.3789 + echo >>$file "** [automatically generated and maintained by GNU shtool]" 1.3790 + echo >>$file "*/" 1.3791 + echo >>$file "" 1.3792 + echo >>$file "#ifdef _${filestr}_AS_HEADER_" 1.3793 + echo >>$file "" 1.3794 + echo >>$file "#ifndef _${filestr}_" 1.3795 + echo >>$file "#define _${filestr}_" 1.3796 + echo >>$file "" 1.3797 + echo >>$file "#define ${prefixupper}VERSION ${vHex}" 1.3798 + echo >>$file "" 1.3799 + echo >>$file "typedef struct {" 1.3800 + echo >>$file " const int v_hex;" 1.3801 + echo >>$file " const char *v_short;" 1.3802 + echo >>$file " const char *v_long;" 1.3803 + echo >>$file " const char *v_tex;" 1.3804 + echo >>$file " const char *v_gnu;" 1.3805 + echo >>$file " const char *v_web;" 1.3806 + echo >>$file " const char *v_sccs;" 1.3807 + echo >>$file " const char *v_rcs;" 1.3808 + echo >>$file "} ${prefix}version_t;" 1.3809 + echo >>$file "" 1.3810 + echo >>$file "extern ${prefix}version_t ${prefix}version;" 1.3811 + echo >>$file "" 1.3812 + echo >>$file "#endif /* _${filestr}_ */" 1.3813 + echo >>$file "" 1.3814 + echo >>$file "#else /* _${filestr}_AS_HEADER_ */" 1.3815 + echo >>$file "" 1.3816 + echo >>$file "#define _${filestr}_AS_HEADER_" 1.3817 + echo >>$file "#include \"${file}\"" 1.3818 + echo >>$file "#undef _${filestr}_AS_HEADER_" 1.3819 + echo >>$file "" 1.3820 + echo >>$file "${prefix}version_t ${prefix}version = {" 1.3821 + echo >>$file " ${vHex}," 1.3822 + echo >>$file " \"${vShort}\"," 1.3823 + echo >>$file " \"${vLong}\"," 1.3824 + echo >>$file " \"${vTeX}\"," 1.3825 + echo >>$file " \"${vGNU}\"," 1.3826 + echo >>$file " \"${vWeb}\"," 1.3827 + echo >>$file " \"${vSCCS}\"," 1.3828 + echo >>$file " \"${vRCS}\"" 1.3829 + echo >>$file "};" 1.3830 + echo >>$file "" 1.3831 + echo >>$file "#endif /* _${filestr}_AS_HEADER_ */" 1.3832 + echo >>$file "" 1.3833 + ;; 1.3834 + m4 ) 1.3835 + echo >>$file "##" 1.3836 + echo >>$file "## ${file} -- Version Information for ${name} (syntax: M4)" 1.3837 + echo >>$file "## [automatically generated and maintained by GNU shtool]" 1.3838 + echo >>$file "##" 1.3839 + echo >>$file "" 1.3840 + echo >>$file "m4_define([v_hex], [${vHex}])" 1.3841 + echo >>$file "m4_define([v_short], [${vShort}])" 1.3842 + echo >>$file "m4_define([v_long], [${vLong}])" 1.3843 + echo >>$file "m4_define([v_tex], [${vTeX}])" 1.3844 + echo >>$file "m4_define([v_gnu], [${vGNU}])" 1.3845 + echo >>$file "m4_define([v_web], [${vWeb}])" 1.3846 + echo >>$file "m4_define([v_sccs], [${vSCCS}])" 1.3847 + echo >>$file "m4_define([v_rcs], [${vRCS}])" 1.3848 + echo >>$file "" 1.3849 + ;; 1.3850 + perl ) 1.3851 + echo >>$file "##" 1.3852 + echo >>$file "## ${file} -- Version Information for ${name} (syntax: Perl)" 1.3853 + echo >>$file "## [automatically generated and maintained by GNU shtool]" 1.3854 + echo >>$file "##" 1.3855 + echo >>$file "" 1.3856 + echo >>$file "our \$${prefix}version = {" 1.3857 + echo >>$file " 'v_hex' => ${vHex}," 1.3858 + echo >>$file " 'v_short' => \"${vShort}\"," 1.3859 + echo >>$file " 'v_long' => \"${vLong}\"," 1.3860 + echo >>$file " 'v_tex' => \"${vTeX}\"," 1.3861 + echo >>$file " 'v_gnu' => \"${vGNU}\"," 1.3862 + echo >>$file " 'v_web' => \"${vWeb}\"," 1.3863 + echo >>$file " 'v_sccs' => \"${vSCCS}\"," 1.3864 + echo >>$file " 'v_rcs' => \"\\${vRCS}/\"" 1.3865 + echo >>$file "};" 1.3866 + echo >>$file "" 1.3867 + echo >>$file "1;" 1.3868 + echo >>$file "" 1.3869 + ;; 1.3870 + python ) 1.3871 + echo >>$file "##" 1.3872 + echo >>$file "## ${file} -- Version Information for ${name} (syntax: Python)" 1.3873 + echo >>$file "## [automatically generated and maintained by GNU shtool]" 1.3874 + echo >>$file "##" 1.3875 + echo >>$file "" 1.3876 + echo >>$file "class ${prefix}version:" 1.3877 + echo >>$file " v_hex = ${vHex}" 1.3878 + echo >>$file " v_short = \"${vShort}\"" 1.3879 + echo >>$file " v_long = \"${vLong}\"" 1.3880 + echo >>$file " v_tex = \"${vTeX}\"" 1.3881 + echo >>$file " v_gnu = \"${vGNU}\"" 1.3882 + echo >>$file " v_web = \"${vWeb}\"" 1.3883 + echo >>$file " v_sccs = \"${vSCCS}\"" 1.3884 + echo >>$file " v_rcs = \"${vRCS}\"" 1.3885 + echo >>$file "" 1.3886 + ;; 1.3887 + * ) echo "$msgprefix:Error: invalid argument to option \`-l': \`$opt_l'" 1>&2 1.3888 + shtool_exit 1 1.3889 + ;; 1.3890 + esac 1.3891 + fi 1.3892 + 1.3893 + shtool_exit 0 1.3894 + ;; 1.3895 + 1.3896 +path ) 1.3897 + ## 1.3898 + ## path -- Deal with program paths 1.3899 + ## Copyright (c) 1998-2007 Ralf S. Engelschall <rse@engelschall.com> 1.3900 + ## 1.3901 + 1.3902 + namelist="$*" 1.3903 + 1.3904 + # check whether the test command supports the -x option 1.3905 + if [ -x /bin/sh ] 2>/dev/null; then 1.3906 + minusx="-x" 1.3907 + else 1.3908 + minusx="-r" 1.3909 + fi 1.3910 + 1.3911 + # split path string 1.3912 + paths="`echo $opt_p |\ 1.3913 + sed -e 's/^:/.:/' \ 1.3914 + -e 's/::/:.:/g' \ 1.3915 + -e 's/:$/:./' \ 1.3916 + -e 's/:/ /g'`" 1.3917 + 1.3918 + # SPECIAL REQUEST 1.3919 + # translate forward to reverse path 1.3920 + if [ ".$opt_r" = .yes ]; then 1.3921 + if [ "x$namelist" = "x." ]; then 1.3922 + rp='.' 1.3923 + else 1.3924 + rp='' 1.3925 + for pe in `IFS="$IFS/"; echo $namelist`; do 1.3926 + rp="../$rp" 1.3927 + done 1.3928 + fi 1.3929 + echo $rp | sed -e 's:/$::' 1.3930 + shtool_exit 0 1.3931 + fi 1.3932 + 1.3933 + # SPECIAL REQUEST 1.3934 + # strip out directory or base name 1.3935 + if [ ".$opt_d" = .yes ]; then 1.3936 + echo "$namelist" |\ 1.3937 + sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' 1.3938 + shtool_exit 0 1.3939 + fi 1.3940 + if [ ".$opt_b" = .yes ]; then 1.3941 + echo "$namelist" |\ 1.3942 + sed -e 's;.*/\([^/]*\)$;\1;' 1.3943 + shtool_exit 0 1.3944 + fi 1.3945 + 1.3946 + # MAGIC SITUATION 1.3947 + # Perl Interpreter (perl) 1.3948 + if [ ".$opt_m" = .yes ] && [ ".$namelist" = .perl ]; then 1.3949 + rm -f $tmpfile >/dev/null 2>&1 1.3950 + touch $tmpfile 1.3951 + found=0 1.3952 + pc=99 1.3953 + for dir in $paths; do 1.3954 + dir=`echo $dir | sed -e 's;/*$;;'` 1.3955 + nc=99 1.3956 + for name in perl perl5 miniperl; do 1.3957 + if [ $minusx "$dir/$name" ] && [ ! -d "$dir/$name" ]; then 1.3958 + perl="$dir/$name" 1.3959 + pv=`$perl -e 'printf("%.3f", $]);'` 1.3960 + echo "$pv:$pc:$nc:$perl" >>$tmpfile 1.3961 + found=1 1.3962 + fi 1.3963 + nc=`expr $nc - 1` 1.3964 + done 1.3965 + pc=`expr $pc - 1` 1.3966 + done 1.3967 + if [ $found = 1 ]; then 1.3968 + perl="`cat $tmpfile | sort -r -u | sed -e 'q' | cut -d: -f4`" 1.3969 + rm -f $tmpfile >/dev/null 2>&1 1.3970 + echo "$perl" 1.3971 + shtool_exit 0 1.3972 + fi 1.3973 + rm -f $tmpfile >/dev/null 2>&1 1.3974 + shtool_exit 1 1.3975 + fi 1.3976 + 1.3977 + # MAGIC SITUATION 1.3978 + # C pre-processor (cpp) 1.3979 + if [ ".$opt_m" = .yes ] && [ ".$namelist" = .cpp ]; then 1.3980 + echo >$tmpfile.c "#include <assert.h>" 1.3981 + echo >>$tmpfile.c "Syntax Error" 1.3982 + # 1. try the standard cc -E approach 1.3983 + cpp="${CC-cc} -E" 1.3984 + (eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out 1.3985 + my_error=`grep -v '^ *+' $tmpfile.out` 1.3986 + if [ ".$my_error" != . ]; then 1.3987 + # 2. try the cc -E approach and GCC's -traditional-ccp option 1.3988 + cpp="${CC-cc} -E -traditional-cpp" 1.3989 + (eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out 1.3990 + my_error=`grep -v '^ *+' $tmpfile.out` 1.3991 + if [ ".$my_error" != . ]; then 1.3992 + # 3. try a standalone cpp command in path and lib dirs 1.3993 + for path in $paths /lib /usr/lib /usr/local/lib; do 1.3994 + path=`echo $path | sed -e 's;/*$;;'` 1.3995 + if [ $minusx "$path/cpp" ] && [ ! -d "$path/cpp" ]; then 1.3996 + cpp="$path/cpp" 1.3997 + break 1.3998 + fi 1.3999 + done 1.4000 + if [ ".$cpp" != . ]; then 1.4001 + (eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out 1.4002 + my_error=`grep -v '^ *+' $tmpfile.out` 1.4003 + if [ ".$my_error" != . ]; then 1.4004 + # ok, we gave up... 1.4005 + cpp='' 1.4006 + fi 1.4007 + fi 1.4008 + fi 1.4009 + fi 1.4010 + rm -f $tmpfile >/dev/null 2>&1 1.4011 + rm -f $tmpfile.c $tmpfile.out >/dev/null 2>&1 1.4012 + if [ ".$cpp" != . ]; then 1.4013 + echo "$cpp" 1.4014 + shtool_exit 0 1.4015 + fi 1.4016 + shtool_exit 1 1.4017 + fi 1.4018 + 1.4019 + # STANDARD SITUATION 1.4020 + # iterate over names 1.4021 + for name in $namelist; do 1.4022 + # iterate over paths 1.4023 + for path in $paths; do 1.4024 + path=`echo $path | sed -e 's;/*$;;'` 1.4025 + if [ $minusx "$path/$name" ] && [ ! -d "$path/$name" ]; then 1.4026 + if [ ".$opt_s" != .yes ]; then 1.4027 + echo "$path/$name" 1.4028 + fi 1.4029 + shtool_exit 0 1.4030 + fi 1.4031 + done 1.4032 + done 1.4033 + 1.4034 + shtool_exit 1 1.4035 + ;; 1.4036 + 1.4037 +esac 1.4038 + 1.4039 +shtool_exit 0 1.4040 +