--- shtool 2000/08/18 15:35:57 1.2
+++ shtool 2001/03/21 16:08:41 1.3
@@ -1,12 +1,12 @@
#!/bin/sh
##
## GNU shtool -- The GNU Portable Shell Tool
-## Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
+## Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>
##
## See http://www.gnu.org/software/shtool/ for more information.
## See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
##
-## Version: 1.5.1 (29-Jul-2000)
+## Version: 1.5.2 (27-Feb-2001)
## Contents: all available modules
##
@@ -63,8 +63,8 @@
exit 1
fi
if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
- echo "This is GNU shtool, version 1.5.1 (29-Jul-2000)"
- echo "Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>"
+ echo "This is GNU shtool, version 1.5.2 (27-Feb-2001)"
+ echo "Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>"
echo "Report bugs to <bug-shtool@gnu.org>"
echo ''
echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
@@ -82,7 +82,7 @@
echo ' prop [-p<str>]'
echo ' move [-v] [-t] [-e] [-p] <src-file> <dst-file>'
echo ' install [-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>]'
- echo ' [-e<ext>] <file> [<file> ...] <path>'
+ echo ' [-e<sed-cmd>] <file> [<file> ...] <path>'
echo ' mkdir [-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]'
echo ' mkln [-t] [-f] [-s] <src-path> [<src-path> ...] <dst-path>'
echo ' mkshadow [-v] [-t] [-a] <src-dir> <dst-dir>'
@@ -101,7 +101,7 @@
exit 0
fi
if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
- echo "GNU shtool 1.5.1 (29-Jul-2000)"
+ echo "GNU shtool 1.5.2 (27-Feb-2001)"
exit 0
fi
if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then
@@ -182,15 +182,15 @@
;;
install )
str_tool="install"
- str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<ext>] <file> [<file> ...] <path>"
+ str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<sed-cmd>] <file> [<file> ...] <path>"
arg_spec="2+"
- opt_spec="v.t.c.C.s.m:o:g:e:"
+ opt_spec="v.t.c.C.s.m:o:g:e+"
opt_v=no
opt_t=no
opt_c=no
opt_C=no
opt_s=no
- opt_m=""
+ opt_m="0755"
opt_o=""
opt_g=""
opt_e=""
@@ -455,6 +455,7 @@
tmpfile="$tmpdir/.shtool.$$"
rm -f $tmpfile >/dev/null 2>&1
touch $tmpfile
+ chmod 600 $tmpfile
fi
##
@@ -466,7 +467,7 @@
echo )
##
## echo -- Print string with optional construct expansion
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for WML as buildinfo
##
@@ -814,7 +815,7 @@
table )
##
## table -- Pretty-print a field-separated list as a table
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for Apache
##
@@ -878,7 +879,7 @@
prop )
##
## prop -- Display progress with a running propeller
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for mod_ssl
##
@@ -923,7 +924,7 @@
move )
##
## move -- Move files with simultaneous substitution
- ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for shtool
##
@@ -1015,7 +1016,7 @@
install )
##
## install -- Install a program, script or datafile
- ## Copyright (c) 1997-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1997-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for shtool
##
@@ -1045,19 +1046,13 @@
for src in $srcs; do
dst=$dstpath
- # If destination is a directory, append the input filename
+ # if destination is a directory, append the input filename
if [ $dstisdir = 1 ]; then
dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
dst="$dst/$dstfile"
fi
- # Add a possible extension to src and dst
- if [ ".$opt_e" != . ]; then
- src="$src$opt_e"
- dst="$dst$opt_e"
- fi
-
- # Check for correct arguments
+ # check for correct arguments
if [ ".$src" = ".$dst" ]; then
echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2
continue
@@ -1067,18 +1062,18 @@
continue
fi
- # Make a temp file name in the destination directory
+ # make a temp file name in the destination directory
dsttmp=`echo $dst |\
sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \
-e "s;\$;/#INST@$$#;"`
- # Verbosity
+ # verbosity
if [ ".$opt_v" = .yes ]; then
echo "$src -> $dst" 1>&2
fi
- # Copy or move the file name to the temp name
- # (because we might be not allowed to change the source)
+ # copy or move the file name to the temp name
+ # (because we might be not allowed to change the source)
if [ ".$opt_C" = .yes ]; then
opt_c=yes
fi
@@ -1094,8 +1089,16 @@
mv $src $dsttmp || exit $?
fi
- # Adjust the target file
- # (we do chmod last to preserve setuid bits)
+ # adjust the target file
+ if [ ".$opt_e" != . ]; then
+ sed='sed'
+ for e in $opt_e; do
+ sed="$sed -e '$e'"
+ done
+ cp $dsttmp $dsttmp.old
+ eval "$sed <$dsttmp.old >$dsttmp" || exit $?
+ rm -f $dsttmp.old
+ fi
if [ ".$opt_s" = .yes ]; then
if [ ".$opt_t" = .yes ]; then
echo "strip $dsttmp" 1>&2
@@ -1114,14 +1117,14 @@
fi
chgrp $opt_g $dsttmp || exit $?
fi
- if [ ".$opt_m" != . ]; then
+ if [ ".$opt_m" != ".-" ]; then
if [ ".$opt_t" = .yes ]; then
echo "chmod $opt_m $dsttmp" 1>&2
fi
chmod $opt_m $dsttmp || exit $?
fi
- # Determine whether to do a quick install
+ # determine whether to do a quick install
# (has to be done _after_ the strip was already done)
quick=no
if [ ".$opt_C" = .yes ]; then
@@ -1132,7 +1135,7 @@
fi
fi
- # Finally install the file to the real destination
+ # finally, install the file to the real destination
if [ $quick = yes ]; then
if [ ".$opt_t" = .yes ]; then
echo "rm -f $dsttmp" 1>&2
@@ -1150,7 +1153,7 @@
mkdir )
##
## mkdir -- Make one or more directories
- ## Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1996-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for public domain by Noah Friedman <friedman@prep.ai.mit.edu>
## Cleaned up and enhanced for shtool
##
@@ -1159,7 +1162,7 @@
for p in ${1+"$@"}; do
# if the directory already exists...
if [ -d "$p" ]; then
- if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
+ if [ ".$opt_f" = .no -a ".$opt_p" = .no ]; then
echo "$msgprefix:Error: directory already exists: $p" 1>&2
errstatus=1
break
@@ -1209,7 +1212,7 @@
mkln )
##
## mkln -- Make link with calculation of relative paths
- ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for shtool
##
@@ -1287,12 +1290,12 @@
# split away a common prefix
prefix=""
- if [ ".$srcdir" = ".$dstdir" ] && [ ".$srcdir" != . ]; then
+ if [ ".$srcdir" = ".$dstdir" -a ".$srcdir" != . ]; then
prefix="$srcdir/"
srcdir=""
dstdir=""
else
- while [ ".$srcdir" != . ] && [ ".$dstdir" != . ]; do
+ while [ ".$srcdir" != . -a ".$dstdir" != . ]; do
presrc=`echo $srcdir | sed -e 's;^\([^/]*\)/.*;\1;'`
predst=`echo $dstdir | sed -e 's;^\([^/]*\)/.*;\1;'`
if [ ".$presrc" != ".$predst" ]; then
@@ -1348,7 +1351,7 @@
mkshadow )
##
## mkshadow -- Make a shadow tree through symbolic links
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for Apache
##
@@ -1465,7 +1468,7 @@
fixperm )
##
## fixperm -- Fix file permissions inside a source tree
- ## Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1996-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for ePerl
##
@@ -1521,7 +1524,7 @@
tarball )
##
## tarball -- Roll distribution tarballs
- ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for shtool
##
@@ -1547,7 +1550,7 @@
for tool in `echo $tools | sed -e 's/,/ /g'`; do
# iterate over paths
for path in $paths; do
- if [ $minusx "$path/$tool" ] && [ ! -d "$path/$tool" ]; then
+ if [ $minusx "$path/$tool" -a ! -d "$path/$tool" ]; then
eval "prg_${prg}=\"$path/$tool\""
break
fi
@@ -1573,7 +1576,7 @@
if [ ".$opt_t" = .yes ]; then
echo "(cd $src && $prg_find . -type f -depth -print) | sed -e 's:^\\.\$::' -e 's:^\\./::' | cat $exclude >>$tmpfile.lst" 1>&2
fi
- (cd $src && find . -type f -depth -print) |\
+ (cd $src && $prg_find . -type f -depth -print) |\
sed -e 's:^\.$::' -e 's:^\./::' | eval cat $exclude >>$tmpfile.lst
else
if [ ".$opt_t" = .yes ]; then
@@ -1747,6 +1750,7 @@
;;
HP-UX:*)
HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ MACHINE=`echo ${MACHINE}|sed -e 's:/:_:'`
echo "${MACHINE}-hp-hpux${HPUXVER}"; exit 0
;;
IRIX:*)
@@ -1930,7 +1934,7 @@
arx )
##
## arx -- Extended archive command
- ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for shtool
##
@@ -2008,7 +2012,7 @@
slo )
##
## slo -- Separate linker options by library class
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for Apache
##
@@ -2057,7 +2061,7 @@
LIBS_DSO=''
# for each library...
- OIFS="$IFS" IFS=':'
+ OIFS="$IFS"; IFS=':'
for lib in $LIBS; do
[ ".$lib" = . ] && continue
@@ -2067,14 +2071,14 @@
found_dir=''
# for each directory...
- OIFS2="$IFS" IFS=":$DIFS"
+ OIFS2="$IFS"; IFS=":$DIFS"
for dir in ${DIRS} switch-to-defdirs ${DIRS_DEFAULT}; do
[ ".$dir" = . ] && continue
[ ".$dir" = .switch-to-defdirs ] && found_indefdir=yes
[ ! -d $dir ] && continue
# search the file
- OIFS3="$IFS" IFS="$DIFS"
+ OIFS3="$IFS"; IFS="$DIFS"
for file in '' `cd $dir && ls lib${lib}.* 2>/dev/null`; do
[ ".$file" = . ] && continue
case $file in
@@ -2123,7 +2127,7 @@
IFS="$OIFS"
# also pass-through unused dirs even if it's useless
- OIFS="$IFS" IFS=':'
+ OIFS="$IFS"; IFS=':'
for dir in $DIRS; do
dirlist="${DIRS_OBJ}:${DIRS_PIC}:${DIRS_DSO}:"
if [ ".`echo \"$dirlist\" | fgrep :$dir:`" = . ]; then
@@ -2134,7 +2138,7 @@
# reassemble the options but separated by type
for type in OBJ PIC DSO; do
- OIFS="$IFS" IFS=':'
+ OIFS="$IFS"; IFS=':'
eval "libs=\"\$LIBS_${type}\""
opts=''
for lib in $libs; do
@@ -2164,7 +2168,7 @@
scpp )
##
## scpp -- Sharing C Pre-Processor
- ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for GNU Pth
##
@@ -2377,7 +2381,7 @@
version )
##
## version -- Maintain a version information file
- ## Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for ePerl, rewritten from scratch for shtool
##
@@ -2535,7 +2539,7 @@
vGNU="${name} ${triple} (${tim})"
vWeb="${name}/${triple}"
vSCCS="@(#)${name} ${triple} (${tim})"
- vRCS="\$Id: shtool,v 1.2 2000/08/18 15:35:57 rse Exp ${name} ${triple} (${tim}) \$"
+ vRCS="\$Id: shtool,v 1.3 2001/03/21 16:08:41 rse Exp ${name} ${triple} (${tim}) \$"
# determine string out of filename
# (do NOT try to optimize this in any way because of portability)
@@ -2655,7 +2659,7 @@
path )
##
## path -- Deal with program paths
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for Apache
##
@@ -2705,7 +2709,7 @@
# MAGIC SITUATION
# Perl Interpreter (perl)
- if [ ".$opt_m" = .yes ] && [ ".$namelist" = .perl ]; then
+ if [ ".$opt_m" = .yes -a ".$namelist" = .perl ]; then
rm -f $tmpfile
touch $tmpfile
found=0
@@ -2714,7 +2718,7 @@
dir=`echo $dir | sed -e 's;/*$;;'`
nc=99
for name in perl perl5 miniperl; do
- if [ $minusx "$dir/$name" ] && [ ! -d "$dir/$name" ]; then
+ if [ $minusx "$dir/$name" -a ! -d "$dir/$name" ]; then
perl="$dir/$name"
pv=`$perl -e 'printf("%.3f", $]);'`
echo "$pv:$pc:$nc:$perl" >>$tmpfile
@@ -2735,7 +2739,7 @@
# MAGIC SITUATION
# C pre-processor (cpp)
- if [ ".$opt_m" = .yes ] && [ ".$namelist" = .cpp ]; then
+ if [ ".$opt_m" = .yes -a ".$namelist" = .cpp ]; then
echo >$tmpfile.c "#include <assert.h>"
echo >>$tmpfile.c "Syntax Error"
# 1. try the standard cc -E approach
@@ -2751,7 +2755,7 @@
# 3. try a standalone cpp command in path and lib dirs
for path in $paths /lib /usr/lib /usr/local/lib; do
path=`echo $path | sed -e 's;/*$;;'`
- if [ $minusx "$path/cpp" ] && [ ! -d "$path/cpp" ]; then
+ if [ $minusx "$path/cpp" -a ! -d "$path/cpp" ]; then
cpp="$path/cpp"
break
fi
@@ -2780,7 +2784,7 @@
# iterate over paths
for path in $paths; do
path=`echo $path | sed -e 's;/*$;;'`
- if [ $minusx "$path/$name" ] && [ ! -d "$path/$name" ]; then
+ if [ $minusx "$path/$name" -a ! -d "$path/$name" ]; then
if [ ".$opt_s" != .yes ]; then
echo "$path/$name"
fi
|