Several of the shell-scripts contain non-POSIXisms (such as XPIisms and BASHisms); this simple patch fixes them.
(Manual) substitutions done: -a and -o => expressions that uses && and || instead type => which trap: use signal-names instead of signal-numbers tail +<num> => tail -n+<num> egrep => grep -E If I've missed anything, feel free to complain. As soon as time permits, I will finish my audit of the rest of the /bin/sh-scripts in base, and submit patches for these as well. Regards: David Weinehall -- /) David Weinehall <[EMAIL PROTECTED]> /) Northern lights wander (\ // Maintainer of the v2.0 kernel // Dance across the winter sky // \) http://www.acc.umu.se/~tao/ (/ Full colour fire (/
diff -ur base-config-2.26/apt-setup base-config-2.26-patched/apt-setup --- base-config-2.26/apt-setup 2004-05-30 01:31:45.000000000 +0200 +++ base-config-2.26-patched/apt-setup 2004-06-11 07:09:29.000000000 +0200 @@ -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="" diff -ur base-config-2.26/base-config base-config-2.26-patched/base-config --- base-config-2.26/base-config 2004-05-30 01:31:50.000000000 +0200 +++ base-config-2.26-patched/base-config 2004-06-11 07:02:56.000000000 +0200 @@ -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.26/lib/menu/hostname base-config-2.26-patched/lib/menu/hostname --- base-config-2.26/lib/menu/hostname 2004-05-30 01:31:49.000000000 +0200 +++ base-config-2.26-patched/lib/menu/hostname 2004-06-11 07:32:03.000000000 +0200 @@ -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.26/lib/menu/pon.tst base-config-2.26-patched/lib/menu/pon.tst --- base-config-2.26/lib/menu/pon.tst 2004-05-30 01:31:49.000000000 +0200 +++ base-config-2.26-patched/lib/menu/pon.tst 2004-06-11 07:33:52.000000000 +0200 @@ -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.26/termwrap base-config-2.26-patched/termwrap --- base-config-2.26/termwrap 2004-05-30 01:31:50.000000000 +0200 +++ base-config-2.26-patched/termwrap 2004-06-11 06:58:54.000000000 +0200 @@ -130,7 +130,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 @@ -170,7 +170,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 which fgconsole >/dev/null && [ serial = "$(fgconsole)" ] ; then TERMINAL=serial else TERMINAL=console @@ -208,7 +208,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 @@ -283,7 +283,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 @@ -341,7 +341,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.26/tzsetup base-config-2.26-patched/tzsetup --- base-config-2.26/tzsetup 2004-05-30 01:31:50.000000000 +0200 +++ base-config-2.26-patched/tzsetup 2004-06-11 06:44:43.000000000 +0200 @@ -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