--- Begin Message ---
Subject: |
Re: Optimization for install-sh |
Date: |
Fri, 10 Nov 2000 15:13:26 +0100 |
User-agent: |
Mutt/1.2.5i |
On Fri, Nov 10, 2000 at 02:54:18PM +0100, Akim Demaille wrote:
: >>>>> "Lars" == Lars J Aas <address@hidden> writes:
:
: Lars> I agree that is wrong. However, $? wasn't used after a lot of
: Lars> the if blocks, so I don't see why you need the "else true; fi"
: Lars> for in those places.
:
: The code is
:
: if .. fi ||
: if .. fi
:
: and || depends upon $?. If you remove the || then of course it is no
: longer needed.
I wasn'rt talking about the if-blocks that was used with && operators,
I was talking about the redundant if/else blocks (excuse the un-related
while-loop compacting on top):
Index: install-sh
===================================================================
RCS file: /cvs/autoconf/install-sh,v
retrieving revision 1.12
diff -C5 -u -r1.12 install-sh
--- install-sh 2000/11/09 20:59:26 1.12
+++ install-sh 2000/11/10 14:09:12
@@ -55,63 +55,53 @@
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
- shift
- continue;;
+ ;;
-d) dir_arg=true
- shift
- continue;;
+ ;;
-m) chmodcmd="$chmodprog $2"
- shift
shift
- continue;;
+ ;;
-o) chowncmd="$chownprog $2"
shift
- shift
- continue;;
+ ;;
-g) chgrpcmd="$chgrpprog $2"
- shift
shift
- continue;;
+ ;;
-s) stripcmd="$stripprog"
- shift
- continue;;
+ ;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
+ ;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
+ ;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
- shift
- continue;;
+ ;;
esac
+ shift
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
-else
- :
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
@@ -126,34 +116,28 @@
# 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 ]
+ if [ ! -f $src -a ! -d $src ]
then
- :
- else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
- else
- :
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
- else
- :
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
@@ -180,12 +164,10 @@
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
- else
- :
fi
pathcomp="${pathcomp}/"
done
fi
@@ -213,12 +195,10 @@
# 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.$$#
--- End Message ---