[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#256302: XSI:isms in several scripts



Package: dpkg
Version: 1.10.22
Severity: minor
Tags: patch

Several scripts in dpkg contains use of the XSI:isms `-a' and `-o' for
`test'/`['.  This is technically a policy-violation.

Rationale:

policy 10.4
http://www.opengroup.org/onlinepubs/009695399/utilities/test.html


Regards: David Weinehall

diff -ur dpkg-1.10.22-old/debian/dpkg.postinst dpkg-1.10.22/debian/dpkg.postinst
--- dpkg-1.10.22-old/debian/dpkg.postinst	2004-06-02 00:18:15.000000000 +0300
+++ dpkg-1.10.22/debian/dpkg.postinst	2004-06-26 01:51:30.000000000 +0300
@@ -19,7 +19,7 @@
 }
 
 if [ "x$1" = xconfigure ]; then
-	if [ -z "$2" -a ! -f /etc/dpkg/dpkg.cfg ] ; then
+	if [ -z "$2" ] && [ ! -f /etc/dpkg/dpkg.cfg ] ; then
 		cp /usr/share/doc/dpkg/dpkg.cfg /etc/dpkg
 	fi
 
@@ -35,7 +35,7 @@
 					continue
 				fi
 				h="`echo $g | sed -e 's/^K/S/'`"
-				if ! [ -L $h -a -L $g ] \
+				if ! [ -L $h ] && [ -L $g ] \
 				  || [ "`ls -Li $g 2>/dev/null | awk '{print $1}'`" != \
 				       "`ls -Li $h 2>/dev/null | awk '{print $1}'`" ]
 				then
@@ -114,8 +114,8 @@
 	esac
 fi
 
-if [ -d /usr/info -a ! -L /usr/info -a ! -L /usr/info/dir \
-		-a -f /usr/info/dir ]; then              
+if [ -d /usr/info ] && [ ! -L /usr/info ] && [ ! -L /usr/info/dir ] \
+		&& [ -f /usr/info/dir ]; then              
 	echo Moving /usr/info/dir to /usr/share/info/dir.
 	mv /usr/info/dir /usr/share/info/dir
 	if [ -f /usr/info/dir.old ]; then
diff -ur dpkg-1.10.22-old/debian/dpkg.prerm dpkg-1.10.22/debian/dpkg.prerm
--- dpkg-1.10.22-old/debian/dpkg.prerm	2004-06-02 00:18:15.000000000 +0300
+++ dpkg-1.10.22/debian/dpkg.prerm	2004-06-26 01:53:55.000000000 +0300
@@ -2,7 +2,7 @@
 
 set -e
 
-if [ ! \( "$1" = "upgrade" -o "$1" = "remove" \) ]; then
+if [ ! "$1" = "upgrade" ] && [ ! "$1" = "remove" ]; then
 	exit 0
 fi
 
diff -ur dpkg-1.10.22-old/methods/disk.setup dpkg-1.10.22/methods/disk.setup
--- dpkg-1.10.22-old/methods/disk.setup	2004-06-02 00:18:16.000000000 +0300
+++ dpkg-1.10.22/methods/disk.setup	2004-06-26 01:55:48.000000000 +0300
@@ -172,7 +172,7 @@
 			read response
 			response="`echo \"$response\" | sed -e 's/[ 	]*$//'`"
 			if expr "$response" : '[0-9][0-9]*$' >/dev/null && \
-			   [ $response -ge 1 -a $response -le $ncdroms ]
+			   [ $response -ge 1 ] && [ $response -le $ncdroms ]
 			then
 				mountpoint="`sed -n $response'p' <$tp.l`"
 				echo
@@ -229,7 +229,7 @@
 		echo -n \
 "What is the name of the NFS server ? [$defaultnfsserver]  "
 		read response
-		if [ -z "$response" -a -n "$defaultnfsserver" ]
+		if [ -z "$response" ] && [ -n "$defaultnfsserver" ]
 		then
 			response="$defaultnfsserver"
 		fi
@@ -262,7 +262,7 @@
 What is the pathname on the NFS server of the filesystem with
 the Debian files? [$defaultnfsrempath]  "
 		read response
-		if [ -z "$response" -a -n "$defaultnfsrempath" ]
+		if [ -z "$response" ] && [ -n "$defaultnfsrempath" ]
 		then
 			response="$defaultnfsrempath"
 		else
@@ -444,7 +444,7 @@
 		check_binary $1 "$hierbase/$3/binary-$iarch"
 	fi
 
-	if [ $option = cdrom -a $2 = nf -a -z "$this_binary" ]
+	if [ $option = cdrom ] && [ $2 = nf ] && [ -z "$this_binary" ]
 	then
 		echo '
 Note: most CD-ROM distributions of Debian do not include programs
@@ -453,7 +453,7 @@
 distribution for profit on a CD-ROM - ie they are not free software.
 If you wish to install these programs you'\''ll have to get them from an
 alternative source.'
-	elif [ $2 = lcl -a -z "$this_binary" ]
+	elif [ $2 = lcl ] && [ -z "$this_binary" ]
 	then
 		echo '
 Note: By default there is no `local'\'' directory. It is intended for 
@@ -466,7 +466,7 @@
 Which directory contains the *.deb packages from the $1 distribution
 area (this directory is named \`$3/binary-$iarch' on the distribution site) ?
 Say \`none' if this area is not available."
-		if [ $2 != main -a -z "$defaultbinary" ]
+		if [ $2 != main ] && [ -z "$defaultbinary" ]
 		then
 			defaultbinary=none
 		fi
@@ -474,7 +474,7 @@
 "Enter _$1_ binary dir. [$4]
  ?  "
 		read response
-		if [ -z "$response" -a -n "$defaultbinary" ]
+		if [ -z "$response" ] && [ -n "$defaultbinary" ]
 		then
 			response="$defaultbinary"
 		fi
@@ -519,7 +519,7 @@
 [$5]
  ?  "
 			read response
-			if [ -z "$response" -a -n "$5" ]
+			if [ -z "$response" ] && [ -n "$5" ]
 			then
 				response="$5"
 			fi
diff -ur dpkg-1.10.22-old/methods/disk.update dpkg-1.10.22/methods/disk.update
--- dpkg-1.10.22-old/methods/disk.update	2004-06-02 00:18:16.000000000 +0300
+++ dpkg-1.10.22/methods/disk.update	2004-06-26 01:56:56.000000000 +0300
@@ -9,9 +9,9 @@
 
 . ./shvar.$option
 
-if [ -z "$p_main_packages" -a -z "$p_ctb_packages" -a \
-     -z "$p_nf_packages" -a -z "$p_nus_packages " -a \
-     -z "$p_lcl_packages" ]
+if [ -z "$p_main_packages" ] && [ -z "$p_ctb_packages" ] && \
+   [ -z "$p_nf_packages" ] && [ -z "$p_nus_packages " ] && \
+   [ -z "$p_lcl_packages" ]
 then
 	echo '
 No Packages files available, cannot update available packages list.
diff -ur dpkg-1.10.22-old/scripts/dpkg-buildpackage.sh dpkg-1.10.22/scripts/dpkg-buildpackage.sh
--- dpkg-1.10.22-old/scripts/dpkg-buildpackage.sh	2004-06-02 00:18:16.000000000 +0300
+++ dpkg-1.10.22/scripts/dpkg-buildpackage.sh	2004-06-26 02:01:37.000000000 +0300
@@ -48,7 +48,7 @@
 
 rootcommand=''
 signcommand=""
-if [ -e $GNUPGHOME/secring.gpg -o -e $HOME/.gnupg/secring.gpg ] && \
+if ( [ -e $GNUPGHOME/secring.gpg ] || [ -e $HOME/.gnupg/secring.gpg ] ) && \
 		command -v gpg > /dev/null 2>&1; then
 	signcommand=gpg
 elif command -v pgp > /dev/null 2>&1 ; then
@@ -120,7 +120,7 @@
 
 if test -n "$forcesigninterface" ; then
   signinterface=$forcesigninterface
-if [ "$signinterface" != "gpg" -a "$signinterface" != "pgp" ] ; then
+if [ "$signinterface" != "gpg" ] && [ "$signinterface" != "pgp" ] ; then
 	echo >&2 "$progname: invalid sign interface specified"
 	exit 1
 fi
@@ -200,7 +200,7 @@
 	withecho $rootcommand debian/rules $binarytarget
 fi
 if [ "$usepause" = "true" ] && \
-   [  "$signchanges" != ":" -o \( -z "$binaryonly"  -a "$signsource" != ":" \) ] ; then
+   ( [ "$signchanges" != ":" ] || ( [ -z "$binaryonly" ] && [ "$signsource" != ":" ] ) ) ; then
     echo Press the return key to start signing process
     read dummy_stuff
 fi
diff -ur dpkg-1.10.22-old/scripts/dpkg-name.sh dpkg-1.10.22/scripts/dpkg-name.sh
--- dpkg-1.10.22-old/scripts/dpkg-name.sh	2004-06-02 00:18:16.000000000 +0300
+++ dpkg-1.10.22/scripts/dpkg-name.sh	2004-06-26 02:03:12.000000000 +0300
@@ -70,7 +70,7 @@
 
 		a=`dpkg-deb -f -- "$1" architecture`;
 		a=`echo $a|sed -e 's/ *//g'`;
-		if [ -z "$a" -a -n "$noarchitecture" ]; # arch field empty, or ignored
+		if [ -z "$a" ] && [ -n "$noarchitecture" ]; # arch field empty, or ignored
 		then
 			a=`dpkg --print-installation-architecture`;
 			stderr "assuming architecture \`"$a"' for \`"$1"'";
@@ -103,7 +103,7 @@
 				s="no-section";
 				stderr "assuming section \`"no-section"' for \`"$1"'";
 			fi
-			if [ "$s" != "non-free" -a "$s" != "contrib" -a "$s" != "no-section" ];
+			if [ "$s" != "non-free" ] && [ "$s" != "contrib" ] && [ "$s" != "no-section" ];
 			then
 				dir=`echo unstable/binary-$a/$s`;
 			else
@@ -147,7 +147,7 @@
 		if [ $newname -ef "$1" ]; # same device and inode numbers
 		then
 			stderr "skipping \`"$1"'";
-		elif [ -f $newname -a -z "$overwrite" ];
+		elif [ -f $newname ] && [ -z "$overwrite" ];
 		then
 			stderr "can't move \`"$1"' to existing file";
 		elif `$command "$1" $newname`;



Reply to: