Bug#256530: XSI:isms in base-config
Package: base-config
Version: 2.32
Severity: minor
Tags: patch
As mentioned earlier on debian-boot, base-config contains use of several
XSI:isms. This patch tries to fix them all.
The following changes are made:
test/[ with -a => expression using &&
test/[ with -o => expression using ||
trap ... <signr> => trap ... <signame>
egrep => grep -E (while not shell-specific, egrep is an extension while
grep -E is a part of POSIX)
type => command -v (while -v is also an extension, discussions on
debian-policy seems to be close to an agreement on command -v being
a reasonable addition to our policy, since POSIX already has command)
I've also added a 2> /dev/null in the where type was used, since the
error-message from type/command -v is output to stderr if the file
doesn't exist, and the return-value is all that matters here.
Rationale:
policy 10.4
http://www.opengroup.org/onlinepubs/009695399/utilities/test.html
http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html
http://www.opengroup.org/onlinepubs/009695399/utilities/grep.html
Other references:
http://www.opengroup.org/onlinepubs/009695399/utilities/command.html
http://www.opengroup.org/onlinepubs/009695399/utilities/type.html
Regards: David Weinehall
diff -ur base-config-2.32-old/apt-setup base-config-2.32/apt-setup
--- base-config-2.32-old/apt-setup 2004-06-13 22:58:15.000000000 +0300
+++ base-config-2.32/apt-setup 2004-06-27 16:38:48.000000000 +0300
@@ -257,7 +257,7 @@
fi
fi
-if [ "$CDPROBE" -a "$CDDEV" ]; then
+if [ "$CDPROBE" ] && [ "$CDDEV" ]; then
umount /cdrom 2>/dev/null || true
# Try mounting the detected cd rom.
if mount $CDDEV /cdrom -o ro -t iso9660 2>/dev/null && scan_cd; then
@@ -285,7 +285,7 @@
# If they chose to use CD, there is little point in asking
# these questions, since the CD's they insert will answer them for us.
# Same goes if they are entering manually.
- if [ "$URI" != "cdrom" -a "$URI" != "edit sources list by hand" ]; then
+ if [ "$URI" != "cdrom" ] && [ "$URI" != "edit sources list by hand" ]; then
db_beginblock
db_fset mirror/suite seen false
db_input low mirror/suite || true
@@ -379,7 +379,7 @@
fi
# Ask about a proxy if no proxy is yet defined.
- if [ "$URI" = "http" -a -z "$http_proxy" ]; then
+ if [ "$URI" = "http" ] && [ -z "$http_proxy" ]; then
if [ ! -e "$APTETC/apt.conf" ] || \
! grep -iq 'Acquire::http::Proxy' $APTETC/apt.conf; then
db_fset mirror/http/proxy seen false
@@ -409,7 +409,7 @@
# Make /dev/cdrom link now, with device
# they entered. This is for later use by
# apt.
- if [ "$CDDEV" -a "$CDDEV" != '/dev/cdrom' ]; then
+ if [ "$CDDEV" ] && [ "$CDDEV" != '/dev/cdrom' ]; then
ln -sf $CDDEV /dev/cdrom
fi
fi
@@ -527,7 +527,7 @@
else
CONTRIB=""
fi
- if [ "$URI" = ftp -o "$URI" = http ]; then
+ if [ "$URI" = ftp ] || [ "$URI" = http ]; then
SEP=//
else
SEP=""
@@ -602,7 +602,7 @@
# some of the time: include those
# * adding it when the user has not: don't include those
-if apt-cache policy | grep "o=Debian,a=" | egrep -qv 'a=(unstable|testing)' && \
+if apt-cache policy | grep "o=Debian,a=" | grep -E -qv 'a=(unstable|testing)' && \
! grep -q '^[^#]*security.debian.org' ${APTETC}sources.list; then
# Figure out what line to add (we're definitely going to add something,
# even if it's just a comment).
diff -ur base-config-2.32-old/base-config base-config-2.32/base-config
--- base-config-2.32-old/base-config 2004-06-24 18:05:35.000000000 +0300
+++ base-config-2.32/base-config 2004-06-27 16:24:43.000000000 +0300
@@ -11,12 +11,12 @@
export TEXTDOMAIN
# Get the parameter past the script invocation.
-if [ -z "$NEW" -a "$1" = new ]; then
+if [ -z "$NEW" ] && [ "$1" = new ]; then
NEW=$1
fi
export NEW
-if [ -x /usr/bin/script -a -z "$BASE_CONFIG_IN_SCRIPT" ]; then
+if [ -x /usr/bin/script ] && [ -z "$BASE_CONFIG_IN_SCRIPT" ]; then
# We want this program to run inside script. So if it's not already
# running, run script.
export BASE_CONFIG_IN_SCRIPT=1
@@ -59,7 +59,7 @@
if [ "$NEW" ]; then
# Trap most signals because a ctrl-c killing base-config
# in the middle of the second stage install would be bad.
- trap "" 1 2 3 15
+ trap "" HUP INT QUIT TERM
if [ "$KEEP_DEBS" != yes ]; then
# Free up some disk space used by the debs that debootstrap
@@ -70,7 +70,7 @@
else
# Running again on an existing install. Just trap ctrl-c, and
# cleanly exit.
- trap cleanup 2
+ trap cleanup INT
fi
ORIG_PRIORITY=$(get_priority)
diff -ur base-config-2.32-old/lib/menu/hostname base-config-2.32/lib/menu/hostname
--- base-config-2.32-old/lib/menu/hostname 2004-06-10 19:35:28.000000000 +0300
+++ base-config-2.32/lib/menu/hostname 2004-06-27 16:20:35.000000000 +0300
@@ -23,7 +23,7 @@
# The interface testing work best if the loopback device is skipped.
# Sorted order to test eth1 before eth0, so that the setting in eth0
# is the one that take effect
- interfaces=`netstat -i | tail +3 | awk '{print $1}' | grep -v '^lo$' | sort -r`
+ interfaces=`netstat -i | tail -n +3 | awk '{print $1}' | grep -v '^lo$' | sort -r`
for interface in $interfaces; do
ip=`/sbin/ifconfig $interface 2>&1 | grep 'inet addr:' | tr a-zA-Z: " " | awk '{print $1}'`
if [ "$ip" ]; then
@@ -53,7 +53,7 @@
if [ 2 -gt "$length" ] || [ "$length" -ge 63 ]; then
return 0
fi
- if echo -n "$part" | egrep -q "^-|-$"; then
+ if echo -n "$part" | grep -E -q "^-|-$"; then
return 0
fi
done
diff -ur base-config-2.32-old/lib/menu/pon.tst base-config-2.32/lib/menu/pon.tst
--- base-config-2.32-old/lib/menu/pon.tst 2004-06-10 19:35:28.000000000 +0300
+++ base-config-2.32/lib/menu/pon.tst 2004-06-27 16:19:58.000000000 +0300
@@ -7,7 +7,7 @@
exit 1
fi
-if [ -x /usr/bin/pon ] && [ -e /etc/ppp/peers/provider -o -x /usr/sbin/pppconfig ]; then
+if [ -x /usr/bin/pon ] && ( [ -e /etc/ppp/peers/provider ] || [ -x /usr/sbin/pppconfig ] ); then
if ! route -n | grep -q '^0\.0\.0\.0'; then
exit 0
else
diff -ur base-config-2.32-old/termwrap base-config-2.32/termwrap
--- base-config-2.32-old/termwrap 2004-06-23 02:35:34.000000000 +0300
+++ base-config-2.32/termwrap 2004-06-27 16:34:02.000000000 +0300
@@ -133,7 +133,7 @@
if ! validlocale $LANG_INST > /dev/null 2>&1; then
# Hm, should we install the 'locales' package if it is missing?
- if [ "$localegen" -a -x $localegen ]; then
+ if [ "$localegen" ] && [ -x $localegen ]; then
if grep -q "^$locale " /usr/share/i18n/SUPPORTED && \
! grep -q "^$locale $charset$" $localeconf 2>/dev/null; then
echo "$locale $charset" >> $localeconf
@@ -184,7 +184,7 @@
case `/usr/bin/tty` in
/dev/console)
# Use fgconsole to detect if it is a serial console.
- if type fgconsole >/dev/null && [ serial = "$(fgconsole)" ] ; then
+ if command -v fgconsole >/dev/null 2> /dev/null && [ serial = "$(fgconsole)" ] ; then
TERMINAL=serial
else
TERMINAL=console
@@ -222,7 +222,7 @@
# If the default linux kernel TERM setting is used for serial consoles, change
# it to vt100. This assume serial consoles understand vt100. Almost
# all terminal programs can handle vt100.
-if [ serial = "$TERMINAL" -a linux = "$TERM" ] ; then
+if [ serial = "$TERMINAL" ] && [ linux = "$TERM" ] ; then
TERM=vt100
fi
@@ -295,7 +295,7 @@
WRAPPER_OPTION="-e"
;;
console)
- if [ "$SUBARCH" != pc9800 -a "$TERMINAL" = console ]; then
+ if [ "$SUBARCH" != pc9800 ] && [ "$TERMINAL" = console ]; then
# Any platform except PC9800 require jfbterm
# to display japanese fonts on console.
try_load_fb
@@ -353,7 +353,7 @@
######################################################################
## Execute Wrapper.
######################################################################
-if [ ! -z "$WRAPPER" -a -x "$WRAPPER" ]; then
+if [ ! -z "$WRAPPER" ] && [ -x "$WRAPPER" ]; then
$WRAPPER $WRAPPER_OPTION /bin/true && exec $WRAPPER $WRAPPER_OPTION $@
# Fallback to C
diff -ur base-config-2.32-old/tzsetup base-config-2.32/tzsetup
--- base-config-2.32-old/tzsetup 2004-06-10 19:35:28.000000000 +0300
+++ base-config-2.32/tzsetup 2004-06-27 16:22:41.000000000 +0300
@@ -154,7 +154,7 @@
3)
# Jump to end if the user doesn't want the time zone changed.
db_get tzconfig/change_timezone
- if [ "$RET" = false -a ! "$CHANGE" ]; then
+ if [ "$RET" = false ] && [ ! "$CHANGE" ]; then
STATE=$(($LASTSTATE - 2))
elif [ -n "$COUNTRY" ]; then
# See if there is a special question for this
@@ -272,7 +272,7 @@
# Set time zone.
db_get tzconfig/change_timezone
- if [ "$RET" = true -o "$CHANGE" ]; then
+ if [ "$RET" = true ] || [ "$CHANGE" ]; then
echo $timezone > /etc/timezone
rm -f /etc/localtime && \
ln -sf /usr/share/zoneinfo/$timezone /etc/localtime
@@ -283,11 +283,11 @@
# changed. This must only be done after the time zone
# file is set up.
db_get tzconfig/gmt
- if [ "$RET" = true -a "$UTC" != yes ]; then
+ if [ "$RET" = true ] && [ "$UTC" != yes ]; then
sed -e 's:^UTC="no":UTC="yes":' -e 's:^UTC=no:UTC=yes:' \
/etc/default/rcS > /etc/default/rcS.new
CHANGEUTC=1
- elif [ "$RET" = false -a "$UTC" != no ]; then
+ elif [ "$RET" = false ] && [ "$UTC" != no ]; then
sed -e 's:^UTC="yes":UTC="no":' -e 's:^UTC=yes:UTC=no:' \
/etc/default/rcS > /etc/default/rcS.new
CHANGEUTC=1
@@ -299,7 +299,7 @@
fi
db_get tzconfig/change_timezone
- if [ "$RET" = true -o "$CHANGE" ]; then
+ if [ "$RET" = true ] || [ "$CHANGE" ]; then
# Display a final message giving the selected zone
# and showing the time in that zone (and UTC for
# comparison) and asking if it looks ok.
@@ -315,7 +315,7 @@
;;
7)
db_get tzconfig/change_timezone
- if [ "$RET" = true -o "$CHANGE" ]; then
+ if [ "$RET" = true ] || [ "$CHANGE" ]; then
# Get the result of that last question, and if it
# is false, loop back to start.
db_get tzconfig/verify_choices
Reply to: