From 8a47fa9512eb355e8f7cbe4b4e7d28373e706a6c Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 11 Aug 2007 21:14:53 +0000 Subject: Coding style change, use -n and -z for variable tests Signed-off-by: Aaron Griffin git-svn-id: http://projects.archlinux.org/svn/initramfs/mkinitcpio@209 880c04e9-e011-0410-abf7-b926e227c9cd --- functions | 20 ++++++++++---------- hooks/filesystems | 6 +++--- hooks/resume | 2 +- init | 10 +++++----- install/autodetect | 2 +- install/base | 2 +- install/fw | 2 +- install/ide | 2 +- install/pata | 2 +- install/pcmcia | 2 +- install/sata | 2 +- install/scsi | 2 +- install/usb | 2 +- install/usbinput | 2 +- mkinitcpio | 12 ++++++------ 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/functions b/functions index abe1cad..69f918b 100644 --- a/functions +++ b/functions @@ -6,7 +6,7 @@ auto_modules () $aliases 2>/dev/null | sed 's|insmod \(.*\)|\1|' | grep ${@} | sort -u) echo "${mods}" - [ "x${mods}" = "x" ] && return 1 + [ -z "${mods}" ] && return 1 return 0 } @@ -15,7 +15,7 @@ all_modules () mods=$(find ${MODULEDIR} -name *.ko 2>/dev/null | grep ${@} | sort -u) echo "${mods}" - [ "x${mods}" = "x" ] && return 1 + [ -z "${mods}" ] && return 1 return 0 } @@ -39,7 +39,7 @@ die () { echo "FATAL: ${@}" >&2; exit 1; } add_full_dir () { - if [ "x${1}" != "x" -a -d "${1}" ]; then + if [ -n "${1}" -a -d "${1}" ]; then for f in ${1}/*; do if [ -d "${f}" ]; then add_full_dir "${f}" @@ -53,7 +53,7 @@ add_full_dir () add_dir () { #skip root directory and "." for relative directories... i.e. /foo/bar/./blah - if [ "x${1}" != "x" -a "${1}" != "/" -a "${1}" != "." ]; then + if [ -n "${1}" -a "${1}" != "/" -a "${1}" != "." ]; then if ! grep "dir ${1} " "${FILELIST}" 2>&1 > /dev/null; then add_dir $(dirname "${1}") msg " adding dir ${1}" @@ -148,7 +148,7 @@ add_module () found=0 for path in $(find "${MODULEDIR}" -type f -name "${fil}.ko"); do for mod in $(/sbin/modinfo -F depends "${path}" | tr ',' ' '); do - if [ "x${mod}" != "x" ]; then + if [ -n "${mod}" ]; then add_module "${mod}" HAS_MODULES="y" fi @@ -190,7 +190,7 @@ add_binary () #note, this will also handle 'not a dynamic executable' spit out by # static binaries... the deps will produce nothing for lib in $(ldd ${bin} 2>/dev/null | sed "s|.*=>\(.*\)|\1|"); do - if [ "x${lib}" != "x" ]; then + if [ -n "${lib}" ]; then #remove TLS libraries notls=$(echo ${lib} | sed 's|/lib/tls.*/\(lib.*\)|/lib/\1|') [ -e "${notls}" ] && lib="${notls}" @@ -210,24 +210,24 @@ parse_hook () { local mod bin fil for mod in $MODULES; do - if [ "x${mod}" != "x" ]; then + if [ -n "${mod}" ]; then add_module "${mod}" fi done for bin in $BINARIES; do - if [ "x${bin}" != "x" ]; then + if [ -n "${bin}" ]; then add_binary "${bin}" fi done for fil in $FILES; do - if [ "x${fil}" != "x" ]; then + if [ -n "${fil}" ]; then add_file "${fil}" fi done - if [ "x${SCRIPT}" != "x" ]; then + if [ -n "${SCRIPT}" ]; then add_file "${HOOKDIR}/${SCRIPT}" "/hooks/${SCRIPT}" fi } diff --git a/hooks/filesystems b/hooks/filesystems index ba29443..306277b 100644 --- a/hooks/filesystems +++ b/hooks/filesystems @@ -2,13 +2,13 @@ run_hook () { msg -n ":: Loading root filesystem module..." - if [ "x${rootfstype}" != "x" ]; then + if [ -n "${rootfstype}" ]; then FSTYPE="${rootfstype}" else if [ ! -e "${root}" ]; then msg "\nAttempting to create root device '${root}'" - if [ "x${rootdelay}" != "x" ]; then + if [ -n "${rootdelay}" ]; then msg -n "Waiting for devices to settle..." /bin/sleep "${rootdelay}" msg "done." @@ -19,7 +19,7 @@ run_hook () if [ "${BLOCKNAME}" = "unknown" ]; then FSTYPE="unknown" echo "ERROR: Failed to parse block device name for '${root}'" - elif [ "x${BLOCKDEVICE}" = "x" ]; then + elif [ -z "${BLOCKDEVICE}" ]; then FSTYPE="unknown" echo "ERROR: Failed to parse block device ids for '${root}'" else diff --git a/hooks/resume b/hooks/resume index 4af85ea..f410051 100644 --- a/hooks/resume +++ b/hooks/resume @@ -16,7 +16,7 @@ run_hook () else suspend2root="/proc/suspend2" fi - if [ -d "${suspend2root}" -a "x${resume2}" != "x" ]; then + if [ -d "${suspend2root}" -a -n "${resume2}" ]; then echo ${resume2} > ${suspend2root}/resume2 echo > ${suspend2root}/do_resume fi diff --git a/init b/init index 0cc2ece..3511286 100644 --- a/init +++ b/init @@ -43,19 +43,19 @@ for cmd in $CMDLINE; do esac done -if [ "x${disablehooks}" != "x" ]; then +if [ -n "${disablehooks}" ]; then for d in $(replace "${disablehooks}" ','); do export "hook_${d}=disabled" done fi -if [ "x${disablemodules}" != "x" ]; then +if [ -n "${disablemodules}" ]; then for d in $(replace "${disablemodules}" ','); do export "mod_${d}=disabled" done fi -if [ "x${earlymodules}" != "x" ]; then +if [ -n "${earlymodules}" ]; then for m in $(replace "${earlymodules}" ','); do /sbin/modprobe -q $m > /dev/null 2>&1 done @@ -109,7 +109,7 @@ if [ ! -b "${root}" ]; then eval $(/bin/parseblock "${root}") if [ "${BLOCKNAME}" = "unknown" ]; then echo "ERROR: Failed to parse block device name for '${root}'" - elif [ "x${BLOCKDEVICE}" = "x" ]; then + elif [ -z "${BLOCKDEVICE}" ]; then echo "ERROR: Failed to parse block device ids for '${root}'" else export root="${BLOCKNAME}" @@ -136,7 +136,7 @@ fi #Special handling if udev is running udevpid=$(/bin/minips -C udevd -o pid=) -if [ "x${udevpid}" != "x" ]; then +if [ -n "${udevpid}" ]; then /bin/kill -9 $udevpid /bin/sleep 0.01 fi diff --git a/install/autodetect b/install/autodetect index e52220e..eba31d3 100644 --- a/install/autodetect +++ b/install/autodetect @@ -23,7 +23,7 @@ install () if [ $UID -eq 0 -o "$(groups | grep disk)" != "" ]; then for fs in $(findfs | sort | uniq); do for mod in $(find "${MODULEDIR}" -type f -name "${fs}.ko"); do - if [ "x${mod}" != "x" ]; then + if [ -n "${mod}" ]; then AUTODETECT="${AUTODETECT} ${mod}" fi done diff --git a/install/base b/install/base index 01d5a04..b601eac 100644 --- a/install/base +++ b/install/base @@ -27,7 +27,7 @@ install () add_file "/lib/initcpio/init" "/init" add_file "${CONFIG}" "/config" - if [ "x${MESSAGE}" != "x" ]; then + if [ -n "${MESSAGE}" ]; then echo -e "${MESSAGE}" > ${MESSAGEFILE} add_file "${MESSAGEFILE}" "/message" fi diff --git a/install/fw b/install/fw index 2f42851..008e8b4 100644 --- a/install/fw +++ b/install/fw @@ -5,7 +5,7 @@ install () MODULES=" $(checked_modules "/firewire/") $(checked_modules "/ieee1394/") " MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} firewire-sbp2 sbp2 sd_mod sr_mod" fi BINARIES="" diff --git a/install/ide b/install/ide index 8d241d8..3840843 100644 --- a/install/ide +++ b/install/ide @@ -5,7 +5,7 @@ install () MODULES=" $(checked_modules "/ide/" | grep -v "legacy") "; MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} ide-disk ide-cd" fi diff --git a/install/pata b/install/pata index c3da76f..2ac1218 100644 --- a/install/pata +++ b/install/pata @@ -6,7 +6,7 @@ install () $(checked_modules "ata/ata_piix")" MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} sd_mod sr_mod" fi diff --git a/install/pcmcia b/install/pcmcia index b5ca7fb..944e2f6 100644 --- a/install/pcmcia +++ b/install/pcmcia @@ -4,7 +4,7 @@ install () { MODULES=" $(checked_modules '/pcmcia/' | grep -ve 'sound' -e 'net') $(checked_modules '/ide/legacy')" MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} sd_mod sr_mod ide-disk ide-cd" fi BINARIES="/sbin/pcmcia-socket-startup.static /sbin/pcmcia-check-broken-cis.static" diff --git a/install/sata b/install/sata index 61f7dda..770bb8f 100644 --- a/install/sata +++ b/install/sata @@ -8,7 +8,7 @@ install () $(checked_modules "ata/pdc_adma") $(checked_modules "ata/ata_piix")" MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} sd_mod sr_mod" fi diff --git a/install/scsi b/install/scsi index 396de33..b1c8062 100644 --- a/install/scsi +++ b/install/scsi @@ -7,7 +7,7 @@ install () $(checked_modules "/fusion/")" MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} sd_mod sr_mod" fi BINARIES="" diff --git a/install/usb b/install/usb index f528322..f3f5bff 100644 --- a/install/usb +++ b/install/usb @@ -5,7 +5,7 @@ install () MODULES=" $(checked_modules "/usb/host" | grep -ve "_cs" -e "sl1811-hcd" -e "isp116x-hcd")" MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} usb_storage sd_mod sr_mod" fi BINARIES="" diff --git a/install/usbinput b/install/usbinput index 3a7196b..d2012b6 100644 --- a/install/usbinput +++ b/install/usbinput @@ -5,7 +5,7 @@ install () MODULES=" $(checked_modules "/usb/host" | grep -ve "_cs" -e "sl1811-hcd" -e "isp116x-hcd") " MODULES=$(echo ${MODULES}) #trim whitespace - if [ "x${MODULES}" != "x" ]; then + if [ -n "${MODULES}" ]; then MODULES="${MODULES} usbhid" fi BINARIES="" diff --git a/mkinitcpio b/mkinitcpio index db0b773..841659b 100644 --- a/mkinitcpio +++ b/mkinitcpio @@ -7,7 +7,7 @@ # following constraints should be enforced: # variables should be quoted and bracketed "${SOMEVAR}" # inline execution should be done with $() instead of backticks -# use "x${var}" = "x" to test for nulls/empty strings +# use -z "${var}" to test for nulls/empty strings # incase of embedded spaces, quote all path names and string comarpisons # #TODO trap and remove FILELIST @@ -143,7 +143,7 @@ fi MODULEDIR="${BASEDIR}/lib/modules/${KERNELVERSION}" -if [ "x${BASEDIR}" != "x" ]; then +if [ -n "${BASEDIR}" ]; then if [ "${BASEDIR:0:1}" != "/" ]; then BASEDIR="$(pwd)/${BASEDIR}" elif [ ! -d "${BASEDIR}" ]; then @@ -158,8 +158,8 @@ if [ ! -f "${CONFIG}" ]; then fi source "${CONFIG}" -if [ -f "${FILELIST}" -a "x${APPEND}" == "x" ]; then - if [ "x${SAVELIST}" == "x" ]; then +if [ -f "${FILELIST}" -a -z "${APPEND}" ]; then + if [ -z "${SAVELIST}" ]; then rm ${FILELIST} touch "${FILELIST}" else @@ -230,7 +230,7 @@ if [ "${HAS_MODULES}" == "y" ]; then fi status=0 -if [ "x$GENIMG" != "x" ]; then +if [ -n "$GENIMG" ]; then echo -n ":: Generating image '${GENIMG}'..." if ! gen_init_cpio ${FILELIST} | gzip -9 > "${GENIMG}"; then echo "FAILED" @@ -240,7 +240,7 @@ if [ "x$GENIMG" != "x" ]; then status=0 fi - if [ "x${SAVELIST}" == "x" ]; then + if [ -z "${SAVELIST}" ]; then rm ${FILELIST} fi rm ${MESSAGEFILE} -- cgit v1.2.3-24-g4f1b