[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
common install-sh?
From: |
Karl Berry |
Subject: |
common install-sh? |
Date: |
Thu, 26 Sep 2002 16:13:04 -0400 |
Not that it's a huge deal, but I noticed that the install-sh script
distributed with automake (including 1.7) was different from the
install-sh in gettext/automake, which was different from the install-sh
in gnulib.
The gnulib version quotes more of the filename variables, hopefully
enough so that filenames with whitespace actually work (I did not
exhaustively test). Also, Jim wrote a second way to do the removal
before the install, I gather to handle being able to install the `rm'
binary itself.
The diffs below also send all the fatal errors to stderr instead of
stdout.
These diffs are relative to the automake version. The glibc/gettext
version seems to be older, at least I didn't see any conflicting changes.
If these look ok, maybe you'd incorporate them into the other distributions,
and we can have one version again ...
Thanks,
karl
*** install-sh 16 Feb 2002 14:23:51 -0000 1.1
--- install-sh 26 Sep 2002 20:04:02 -0000
***************
*** 55,62 ****
dir_arg=""
while [ x"$1" != x ]; do
! case "$1" in
! -c) instcmd=$cpprog
shift
continue;;
--- 55,62 ----
dir_arg=""
while [ x"$1" != x ]; do
! case $1 in
! -c) instcmd="$cpprog"
shift
continue;;
***************
*** 79,85 ****
shift
continue;;
! -s) stripcmd=$stripprog
shift
continue;;
--- 79,85 ----
shift
continue;;
! -s) stripcmd="$stripprog"
shift
continue;;
***************
*** 106,121 ****
if [ x"$src" = x ]
then
! echo "install: no input file specified" >&2
exit 1
else
! true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
!
if [ -d "$dst" ]; then
instcmd=:
chmodcmd=""
--- 106,121 ----
if [ x"$src" = x ]
then
! echo "install-sh: no input file specified" >&2
exit 1
else
! :
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
!
if [ -d "$dst" ]; then
instcmd=:
chmodcmd=""
***************
*** 125,147 ****
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
! # might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
! if [ -f "$src" -o -d "$src" ]
then
! true
else
! echo "install: $src does not exist" >&2
exit 1
fi
!
if [ x"$dst" = x ]
then
! echo "install: no destination specified" >&2
exit 1
else
! true
fi
# If destination is a directory, append the input filename; if your system
--- 125,147 ----
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
! # might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
! if [ -f "$src" ] || [ -d "$src" ]
then
! :
else
! echo "install-sh: $src does not exist" >&2
exit 1
fi
!
if [ x"$dst" = x ]
then
! echo "install-sh: no destination specified" >&2
exit 1
else
! :
fi
# If destination is a directory, append the input filename; if your system
***************
*** 149,157 ****
if [ -d "$dst" ]
then
! dst=$dst/`basename "$src"`
else
! true
fi
fi
--- 149,157 ----
if [ -d "$dst" ]
then
! dst="$dst"/`basename "$src"`
else
! :
fi
fi
***************
*** 165,225 ****
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
! IFS="${IFS-$defaultIFS}"
! oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
! set - `echo "$dstdir" | sed -e 's@/@address@hidden' -e 'address@hidden@/@'`
! IFS=$oIFS
pathcomp=''
while [ $# -ne 0 ] ; do
! pathcomp=$pathcomp$1
shift
! if [ ! -d "$pathcomp" ] ;
then
! $mkdirprog "$pathcomp"
else
! true
fi
! pathcomp=$pathcomp/
done
fi
if [ x"$dir_arg" != x ]
then
! $doit $instcmd "$dst" &&
! if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else true ; fi &&
! if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else true ; fi &&
! if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else true ; fi &&
! if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
! if [ x"$transformarg" = x ]
then
dstfile=`basename "$dst"`
else
! dstfile=`basename "$dst" $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
! if [ x"$dstfile" = x ]
then
dstfile=`basename "$dst"`
else
! true
fi
! # Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/#inst.$$#
rmtmp=$dstdir/#rm.$$#
--- 165,225 ----
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
! IFS="${IFS-${defaultIFS}}"
! oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
! set - `echo ${dstdir} | sed -e 's@/@address@hidden' -e 'address@hidden@/@'`
! IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
! pathcomp="${pathcomp}${1}"
shift
! if [ ! -d "${pathcomp}" ] ;
then
! $mkdirprog "${pathcomp}"
else
! :
fi
! pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
! $doit $instcmd $dst &&
! if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
! if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
! if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
! if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
else
# If we're going to rename the final executable, determine the name now.
! if [ x"$transformarg" = x ]
then
dstfile=`basename "$dst"`
else
! dstfile=`basename "$dst" $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
! if [ x"$dstfile" = x ]
then
dstfile=`basename "$dst"`
else
! :
fi
! # Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
rmtmp=$dstdir/#rm.$$#
***************
*** 231,237 ****
# Move or copy the file name to the temp name
! $doit $instcmd $src "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits
--- 231,237 ----
# Move or copy the file name to the temp name
! $doit $instcmd "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits
***************
*** 239,248 ****
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
! if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp";else true;fi &&
! if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp";else true;fi &&
! if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp";else true;fi &&
! if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp";else true;fi &&
# Now remove or move any old file at destination location. We try this
# two ways since rm can't unlink itself on some systems and the destination
--- 239,248 ----
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
! if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
! if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
! if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
! if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
# Now remove or move any old file at destination location. We try this
# two ways since rm can't unlink itself on some systems and the destination
***************
*** 255,261 ****
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
{
! echo "install: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit
}
else
--- 255,261 ----
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
{
! echo "install-sh: cannot unlink or rename $dstdir/$dstfile"
>&2
(exit 1); exit
}
else
***************
*** 265,273 ****
# Now rename the file to the real destination.
! $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
fi &&
# The final little trick to "correctly" pass the exit status to the exit trap.
--- 265,274 ----
# Now rename the file to the real destination.
! $doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
+
# The final little trick to "correctly" pass the exit status to the exit trap.
- common install-sh?,
Karl Berry <=