--- shtool 2000/11/20 19:48:39 1.5
+++ shtool 2001/04/27 12:22:21 1.6
@@ -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.3 (19-Apr-2001)
## Contents: 6/17 available modules
##
@@ -26,7 +26,7 @@
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
## USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
##
-## Notice: Given that you include this file verbatim into your own
+## NOTICE: Given that you include this file verbatim into your own
## source tree, you are justified in saying that it remains separate
## from your package, and that this way you are simply just using GNU
## shtool. So, in this situation, there is no requirement that your
@@ -65,8 +65,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.3 (19-Apr-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>]]"
@@ -80,11 +80,11 @@
echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
echo ' echo [-n] [-e] [<str> ...]'
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 ' fixperm [-v] [-t] <path> [<path> ...]'
- echo ' tarball [-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u'
- echo ' <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]'
+ echo ' tarball [-t] [-v] [-o<tarball>] [-c<prog>] [-d<dir>] [-u<user>]'
+ echo ' [-g<group>] [-e<pattern>] <path> [<path> ...]'
echo ' version [-l<lang>] [-n<name>] [-p<prefix>] [-s<version>] [-e]'
echo ' [-i<knob>] [-d<type>] <file>'
echo ''
@@ -105,7 +105,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.3 (19-Apr-2001)"
exit 0
fi
if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then
@@ -147,15 +147,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=""
@@ -180,7 +180,7 @@
;;
tarball )
str_tool="tarball"
- str_usage="[-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]"
+ str_usage="[-t] [-v] [-o<tarball>] [-c<prog>] [-d<dir>] [-u<user>] [-g<group>] [-e<pattern>] <path> [<path> ...]"
gen_tmpfile=yes
arg_spec="1+"
opt_spec="t.v.o:c:d:u:g:e:"
@@ -353,6 +353,7 @@
tmpfile="$tmpdir/.shtool.$$"
rm -f $tmpfile >/dev/null 2>&1
touch $tmpfile
+ chmod 600 $tmpfile
fi
##
@@ -364,7 +365,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
##
@@ -587,7 +588,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
##
@@ -617,19 +618,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
@@ -639,18 +634,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
@@ -666,8 +661,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
@@ -686,14 +689,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
@@ -704,7 +707,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
@@ -722,7 +725,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
##
@@ -731,7 +734,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
@@ -745,6 +748,12 @@
echo "mkdir $p" 1>&2
fi
mkdir $p || errstatus=$?
+ if [ ".$opt_m" != . ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "chmod $opt_m $p" 1>&2
+ fi
+ chmod $opt_m $p || errstatus=$?
+ fi
else
# the smart situation
set fnord `echo ":$p" |\
@@ -781,7 +790,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
##
@@ -837,7 +846,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
##
@@ -863,7 +872,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
@@ -889,7 +898,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
@@ -1000,7 +1009,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
##
|