use 'test -n "..."' instead of 'test "..."'; when "..." expands to '-v'
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 27 Jan 2005 21:24:44 +0000 (21:24 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 27 Jan 2005 21:24:44 +0000 (21:24 +0000)
or a similar string, the expression will be misinterpreted (noticed by
Werner Schalk)

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1825 94cd875c-1c1d-0410-91d2-eb244daf1a30

19 files changed:
util-vserver/scripts/functions
util-vserver/scripts/pkgmgmt
util-vserver/scripts/start-vservers
util-vserver/scripts/vapt-get
util-vserver/scripts/vpkg
util-vserver/scripts/vprocunhide
util-vserver/scripts/vrpm
util-vserver/scripts/vrpm-preload
util-vserver/scripts/vserver
util-vserver/scripts/vserver-build
util-vserver/scripts/vserver-build.debootstrap
util-vserver/scripts/vserver-build.functions.rpm
util-vserver/scripts/vserver-setup.functions
util-vserver/scripts/vserver-wrapper
util-vserver/scripts/vserver.functions
util-vserver/scripts/vserver.start
util-vserver/scripts/vserver.stop
util-vserver/scripts/vshelper
util-vserver/scripts/vsomething

index 44afc5a..b26e3d8 100644 (file)
@@ -31,11 +31,11 @@ function findObject
     shift 2
     
     for _fo_i; do
-       test "$_fo_i"            || continue
+       test -n "$_fo_i"         || continue
        test ! $_fo_mod "$_fo_i" || { _fo_file=$_fo_i; break; }
     done
 
-    test -z "$_fo_i" -o "$_fo_file" || {
+    test -z "$_fo_i" -o -n "$_fo_file" || {
        echo "Can not find file for '$_fo_var'; aborting"
        exit 1
     } >&2
@@ -62,7 +62,7 @@ function findAndCopy
     shift
     findFile tmp "$@"
 
-    test "$tmp" -a -s "$tmp" || return 0
+    test -n "$tmp" -a -s "$tmp" || return 0
     $_CP -af "$tmp" "$dst"
 }
 
@@ -74,7 +74,7 @@ function getPhysicalDir
 ## Usage: logging <message>
 function logging
 {
-    if test "$_VS_LOGFILE"; then
+    if test -n "$_VS_LOGFILE"; then
        echo "$@" >>"$_VS_LOGFILE"
     else
        echo "$@"
@@ -84,7 +84,7 @@ function logging
 ## Usage: warning <message>
 function warning
 {
-    if test "$_VS_ERRFILE"; then
+    if test -n "$_VS_ERRFILE"; then
        echo "$@" >>"$_VS_ERRFILE"
     else
        echo "$@" >&2
@@ -94,7 +94,7 @@ function warning
 ## Usage: panic <message>
 function panic
 {
-    if test "$_VS_ERRFILE"; then
+    if test -n "$_VS_ERRFILE"; then
        echo "$@" >>"$_VS_ERRFILE"
     else
        echo "$@" >&2
@@ -115,7 +115,7 @@ function execute
 function isNumber
 {
     local tmp
-    let tmp=$1+0 2>/dev/null || test -z "${1//0/}" -a "$1" || return 1
+    let tmp=$1+0 2>/dev/null || test -z "${1//0/}" -a -n "$1" || return 1
     return 0
 }
 
@@ -130,7 +130,7 @@ function colorize
     else
        local   cfile
        findFile cfile "$CONFDIR"/.defaults/styles/"$style" ''
-       if test "$cfile"; then
+       if test -n "$cfile"; then
          $_CAT "$cfile"
        else
          case "$style" in
@@ -242,7 +242,7 @@ function _pkgSetVarsBase
 
 function _pkgSetVarsRPM
 {
-    if test "$PKGDIR"; then
+    if test -n "$PKGDIR"; then
        findDir RPMETCDIR    $PKGDIR/rpmetc      $PKGDIR/base/rpm/etc       /etc/rpm
        findDir RPMSTATEDIR  $PKGDIR/rpmstate    $PKGDIR/base/rpm/state
 
@@ -260,7 +260,7 @@ function _pkgSetVarsRPM
 
 function _pkgSetVarsApt
 {
-    if test "$PKGDIR"; then
+    if test -n "$PKGDIR"; then
        findDir APTETCDIR    $PKGDIR/aptetc      $PKGDIR/base/apt/etc       /etc/apt
        findDir APTSTATEDIR  $PKGDIR/aptstate    $PKGDIR/base/apt/state
        findDir APTCACHEDIR  $PKGDIR/aptcache    $PKGDIR/base/apt/cache
@@ -278,7 +278,7 @@ function _pkgSetVarsApt
 
 function _pkgSetVarsYum
 {
-    if test "$PKGDIR"; then
+    if test -n "$PKGDIR"; then
        findDir YUMETCDIR    $PKGDIR/yumetc      $PKGDIR/base/yum/etc       /etc
        findDir YUMCACHEDIR  $PKGDIR/yumcache    $PKGDIR/base/yum/cache
     else
@@ -321,7 +321,7 @@ function _pkgMountRPM
 
 function _pkgSetEnvBase
 {
-    test "$EXECDIR"   = "/" || {
+    test "$EXECDIR" = "/" || {
        PATH=$EXECDIR:$PATH
        LD_LIBRARY_PATH=$EXECDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
     }
@@ -444,7 +444,7 @@ function getVserverStatus
     read _gvs_ctx <"$1"/run
     eval "$2"=\$_gvs_ctx
 
-    test "$3"        || return 0
+    test -n "$3"     || return 0
     local _gvs_tmp
     _getProcNumberCount "$_gvs_ctx" _gvs_tmp
     eval "$3"=\$_gvs_tmp
@@ -472,7 +472,7 @@ function isVserverRunning
     local _ivr_ctx _ivr_procnum
 
     getVserverStatus "$1" _ivr_ctx _ivr_procnum 1 || return 1
-    test $_ivr_procnum != 0                       || return 1
+    test "$_ivr_procnum" != 0                     || return 1
     test -z "$2" || eval "$2"=\$_ivr_ctx
     return 0
 }
@@ -485,7 +485,7 @@ function getFileValue
     shift
 
     findFile _gfv_file "$@" ''
-    test "$_gfv_file" -a -r "$_gfv_file" || return 0
+    test -n "$_gfv_file" -a -r "$_gfv_file" || return 0
     eval read "$_gfv_var" <"$_gfv_file"
 }
 
@@ -543,7 +543,7 @@ function callInNamespace
     ctx=$( $_VSERVER_INFO "$1" CONTEXT f ) || ctx=
 
     shift
-    if test "$ctx"; then
+    if test -n "$ctx"; then
        $_VNAMESPACE --enter "$ctx" -- "$@"
     else
        "$@"
@@ -574,7 +574,7 @@ function pkgmgmt.guessStyle()
     }
     local _pgs_cfgdir=$($_VSERVER_INFO "$1" APPDIR pkgmgmt) || :
 
-    if test "$_pgs_cfgdir" -a -e "$_pgs_cfgdir"/style; then
+    if test -n "$_pgs_cfgdir" -a -e "$_pgs_cfgdir"/style; then
        read style <"$_pgs_cfgdir"/style
     elif test -e "$_pgs_vdir"/etc/redhat-release -o -e "$_pgs_vdir"/etc/fedora-release; then
        style=redhat
@@ -613,7 +613,7 @@ function pkgmgmt.isAptAvailable
     local is_internal="$3"
     
     local have_apt i
-    if test "$is_internal"; then
+    if test -n "$is_internal"; then
        have_apt=1
        test -d "$cfgdir"/base/apt -o -d "$cfgdir"/aptetc || have_apt=
     else
@@ -623,7 +623,7 @@ function pkgmgmt.isAptAvailable
        done
     fi
 
-    test "$have_apt" && return 0 || return 1
+    test -n "$have_apt" && return 0 || return 1
 }
 
 ## Usage: pkgmgmt.isYumAvailable <cfgdir> <vdir> [<is-internal>]
@@ -634,7 +634,7 @@ function pkgmgmt.isYumAvailable
     local is_internal="$3"
     
     local have_yum i
-    if test "$is_internal"; then
+    if test -n "$is_internal"; then
        have_yum=1
        test -d "$cfgdir"/base/yum -o -d "$cfgdir"/yumetc || have_yum=
     else
@@ -644,7 +644,7 @@ function pkgmgmt.isYumAvailable
        done
     fi
 
-    test "$have_yum" && return 0 || return 1
+    test -n "$have_yum" && return 0 || return 1
 }
 
 
@@ -731,7 +731,7 @@ function vshelper.isEnabled
     local f=${1:+$1-}disabled
     test ! -e "$CONFDIR"/.defaults/apps/vshelper/"$f"       || return 1
     $_VSERVER_INFO - FEATURE vshelper                       || return 1
-    if test "$2"; then
+    if test -n "$2"; then
        local appdir=$($_VSERVER_INFO "$2" APPDIR vshelper) || return 0
        test -z "$2" -o ! -e "$appdir/$f"                   || return 1
     fi
@@ -789,7 +789,7 @@ function vshelper.doInit
 {
     vshelper.isEnabled || return 0
     
-    local xid=$($_VSERVER_INFO "$1" CONTEXT false) && test "$xid" || {
+    local xid=$($_VSERVER_INFO "$1" CONTEXT false) && test -n "$xid" || {
        warning $"vshelper.init: can not determine xid of vserver '$vserver'; returned value was '$xid'"
        return 1
     }
@@ -801,7 +801,7 @@ function vshelper.doInit
     echo "$1" >"$f"
     set +C
     
-    if test "$2"; then
+    if test -n "$2"; then
        shift 1
        local i
        for i; do
@@ -843,7 +843,7 @@ function vshelper.getSyncTimeout
     local _vgst_file _vgst_tmp
 
     findFile _vgst_file ${_vgst_appdir:+"$_vgst_appdir"/sync-timeout} "$CONFDIR"/.defaults/apps/vshelper/sync-timeout ''
-    test "$_vgst_file" || return 1
+    test -n "$_vgst_file" || return 1
     read _vgst_tmp <"$_vgst_file"
     eval $2=\$_vgst_tmp
 }
@@ -853,7 +853,7 @@ function _rpmFake.getCapFlags
 {
     local ctx=$1
     
-    if test "$ctx" && ! $_VSERVER_INFO - FEATURE migrate; then
+    if test -n "$ctx" && ! $_VSERVER_INFO - FEATURE migrate; then
        set -- $($_CHCONTEXT_COMPAT --xid 1 \
            $_SH -c "$_CAT /proc/[0-9]*/status | $_EGREP '^(CapBset|s_context|ctxflags)'" | \
            $_GREP -B 1 -A 1 "^s_context: $ctx " | \
@@ -862,7 +862,7 @@ function _rpmFake.getCapFlags
        set --
     fi
 
-    if test "$3"; then
+    if test -n "$3"; then
        RPM_FAKE_CAP=$[ ~0x$1 ]
        RPM_FAKE_FLAGS=$3
     else
index 9a644b3..933a1c1 100755 (executable)
@@ -60,7 +60,7 @@ function init()
 function _createDirs()
 {
     for i; do
-       test "$i" || continue
+       test -n "$i" || continue
        mkdir -p -m755 "$i"
     done
 }
@@ -138,7 +138,7 @@ function _mountFilesystems()
        echo "Can not determine configuration directory for '$1'; ..." >&2
        return 1
     }
-    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
+    test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
     
     _mountFilesystemsInternal "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || return 1
     _mountFilesystemsInternal "$cfgdir"/fstab.local $_CHBIND "${CHBIND_OPTS[@]}" || return 1
@@ -152,14 +152,14 @@ function _umountFilesystems()
     }
     local vdir=$cfgdir/vdir
     local is_ok=1
-    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
+    test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
 
     pushd "$vdir/" >/dev/null || return 1
        _umountVserverInternal  "$cfgdir"/fstab.local                              || is_ok=
        _umountVserverInternal  "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
     popd >/dev/null           || return 1
     
-    test "$is_ok"
+    test -n "$is_ok"
 }
 
 function processVserver_RH()
@@ -186,7 +186,7 @@ function processVserver_RH()
 
     ## Create directories and assign variables where configuration
     ## can/will be found on the host
-    if test "$is_internalize"; then
+    if test -n "$is_internalize"; then
        pushd "$vdir" >/dev/null
 
        test ! -L var/lib/rpm || {
@@ -205,7 +205,7 @@ function processVserver_RH()
        
        popd >/dev/null
        
-       if test "$have_apt"; then
+       if test -n "$have_apt"; then
            findDir APTETCDIR    "$cfgdir"/aptetc "$cfgdir"/base/apt/etc /etc/apt /
        fi
 
@@ -215,7 +215,7 @@ function processVserver_RH()
        mkdir -m755 -p "$cfgdir"
        local need_base=
 
-       if test "$have_apt"; then
+       if test -n "$have_apt"; then
            findDir APTETCDIR    "$cfgdir"/aptetc      "$cfgdir"/base/apt/etc       /
            findDir APTSTATEDIR  "$cfgdir"/aptstate    "$cfgdir"/base/apt/state     /
            findDir APTCACHEDIR  "$cfgdir"/aptcache    "$cfgdir"/base/apt/cache     /
@@ -247,8 +247,8 @@ function processVserver_RH()
     fi
 
     ## Copy the files...
-    if test "$is_internalize"; then
-       if test "$have_apt"; then
+    if test -n "$is_internalize"; then
+       if test -n "$have_apt"; then
            _copySecure "$vdir" "$APTETCDIR" /etc/apt
            pushd "$vdir" >/dev/null
                _hashAuto /etc/apt/apt.conf '/'
@@ -259,7 +259,7 @@ function processVserver_RH()
        _copySecure "$vdir" "$RPMSTATEDIR" /var/lib/rpm
 
     else
-       if test "$have_apt"; then
+       if test -n "$have_apt"; then
            _copySecureRev "$vdir" /etc/apt "$APTETCDIR"
            _unhashAuto "$APTETCDIR"/apt.conf '/'
        fi
@@ -269,7 +269,7 @@ function processVserver_RH()
     fi
 
     ## Cleanups...
-    if test "$is_internalize"; then
+    if test -n "$is_internalize"; then
        :
     else
        tmpdir=$($_MKTEMPDIR /var/tmp/pgmgmt.XXXXXX)
@@ -281,7 +281,7 @@ function processVserver_RH()
     fi
 
     ## Finish it...
-    if test "$is_internalize"; then
+    if test -n "$is_internalize"; then
        $_TOUCH "$cfgdir"/internal
     else
        $_RM -f "$cfgdir"/internal
@@ -293,7 +293,7 @@ function processVserver_Debian()
     local vserver=$1
     local is_internalize=$2
 
-    if test "$is_internalize"; then
+    if test -n "$is_internalize"; then
        echo $"Debian vservers should be internalized everytime; do not know how to handle '$vserver'" >&2
     else
        echo $"External packagemanagement is not supported for Debian vserver" >&2
@@ -367,7 +367,7 @@ while true; do
     shift
 done
 
-test "$1" || {
+test -n "$1" || {
     echo $"No vserver specified; try '--help' for more information"
     exit 1
 } >&2
index 2b50c45..b9ce07a 100755 (executable)
@@ -108,7 +108,7 @@ while test $i -gt 0; do
     let --i
     d=$CONFDIR/${vservers[$i]}/apps/init
     f=$d/mark
-    { test "$OPTION_MARK" -a -r "$f" && grep -qx "$OPTION_MARK" "$f"; } || \
+    { test -n "$OPTION_MARK" -a -r "$f" && grep -qx "$OPTION_MARK" "$f"; } || \
     { test -z "$OPTION_MARK" && test ! -e "$f"; } || \
     unset vservers[$i]
 done
index 5cdf1a3..3cc203c 100755 (executable)
@@ -73,7 +73,7 @@ res=255
 for i in "${vservers[@]}"; do
     cnt=$[ cnt + 1 ]
 
-    test "$is_quiet" || {
+    test -n "$is_quiet" || {
        colorize bold echo -n "vaptget: operating on vserver "
        colorize bold colorize emph echo "$i"
        xtermTitle "vaptget: operating on vserver '$i'  [$cnt/${#vservers[@]}]"
@@ -87,12 +87,12 @@ for i in "${vservers[@]}"; do
     fi
     res=$?
 
-    test $res -eq 0 -o "$is_quiet" || {
+    test $res -eq 0 -o -n "$is_quiet" || {
        colorize error echo -n $"vapt-get failed on vserver '$i' with errorcode $res"
        echo
     }
        
-    test "$is_quiet" || echo
+    test -n "$is_quiet" || echo
 done
 
 test "$cnt" -ge 0 || echo "No vservers specified" >&2
index 2188dfd..69d5b5b 100755 (executable)
@@ -91,7 +91,7 @@ case "$style" in
                ;;
        esac
        
-       if test "$is_external"; then
+       if test -n "$is_external"; then
            have_apt=1
            test -d "$cfgdir"/base/apt -o -d "$cfgdir"/aptetc || have_apt=
        else
@@ -101,7 +101,7 @@ case "$style" in
            done
        fi
        
-       if test "$is_external"; then
+       if test -n "$is_external"; then
            if test "$have_apt" -a "$apt_param"; then
                cmd=( "$_VAPT_GET" "$vserver" -- "${apt_param[@]}" )
            else
@@ -125,7 +125,7 @@ case "$style" in
                ;;
        esac
 
-       if test "$is_external"; then
+       if test -n "$is_external"; then
            echo $"'external' packagemanagement is not supported for Debian" >&2
            exit 1
        else
index 04b6d0c..f4044af 100755 (executable)
@@ -53,7 +53,7 @@ the GNU General Public License.  This program has absolutely no warranty."
 }
 
 
-while test "$1"; do
+while test -n "$1"; do
     case "$1" in
        --help)         showHelp;;
        --version)      showVersion;;
@@ -90,6 +90,6 @@ while read filename; do
     $_SETATTR -x "${params[@]}" "$@" &&        passed=1 || ok=
 done <"$UNHIDEFILE"
 
-test "$ok"     && exit 0 || \
-test "$passed" && exit 2 || \
+test -n "$ok"     && exit 0 || \
+test -n "$passed" && exit 2 || \
 exit 3
index fc3b9ad..de53ec8 100755 (executable)
@@ -83,7 +83,7 @@ res=255
 for i in "${vservers[@]}"; do
     cnt=$[ cnt + 1 ]
 
-    test "$is_quiet" || {
+    test -n "$is_quiet" || {
        colorize bold echo -n "vrpm: operating on vserver "
        colorize bold colorize emph echo "$i"
        xtermTitle "vrpm: operating on vserver '$i'  [$cnt/${#vservers[@]}]"
@@ -102,7 +102,7 @@ for i in "${vservers[@]}"; do
        echo
     }
 
-    test "$is_quiet" || echo
+    test -n "$is_quiet" || echo
 done
 
 test -z "$do_unify" || echo "unify currently unsupported" >&2
index 181ecae..db99902 100755 (executable)
@@ -30,7 +30,7 @@ for bin in `which rpm` /bin/rpm /usr/lib/rpm/rpm${RPM_FLAVOR:-i} ""; do
     ldd "$bin" &>/dev/null && break
 done
 
-test "$bin" ||
+test -x "$bin" ||
     panic $"No dynamically linked rpm binary found; exiting..."
 
 rpmFake.init "$CUR_VSERVER"
index c313d48..9803a2e 100755 (executable)
@@ -166,7 +166,7 @@ case "$vserver" in
          ;;
 esac
 
-if test "$allow_legacy"; then
+if test -n "$allow_legacy"; then
     do_legacy=
     test ! -e "$VSERVER_DIR/legacy" || do_legacy=1
     test -d "$VSERVER_DIR" -o ! -e "$CONFDIR/$vserver.conf" || do_legacy=1
@@ -195,7 +195,7 @@ else
     VSERVER_NAME=$(basename "$VSERVER_DIR")
 fi
 
-test "$2" != start -o "$OPTION_NONAMESPACE" || isAvoidNamespace "$VSERVER_DIR" || \
+test "$2" != start -o -n "$OPTION_NONAMESPACE" || isAvoidNamespace "$VSERVER_DIR" || \
     exec $_VNAMESPACE --new -- $_VSERVER ----nonamespace "${OPTIONS_ORIG[@]}"
 
 . $PKGLIBDIR/vserver.functions
index 994e3cd..d64c98e 100755 (executable)
@@ -83,7 +83,7 @@ the GNU General Public License.  This program has absolutely no warranty."
 set -e
 
 declare -a default_opts=()
-test "$NO_DEFAULT_OPTS" || getFileArray default_opts "$CONFDIR/.defaults/apps/build/options" || :
+test -n "$NO_DEFAULT_OPTS" || getFileArray default_opts "$CONFDIR/.defaults/apps/build/options" || :
 
 tmp=$(getopt -o +m:n: --long force,debug,help,version,rootdir:,pkgbase:,$SETUP_OPTIONS -n "$(basename $0)" -- \
        "${default_opts[@]}" "$@") || exit 1
@@ -105,16 +105,14 @@ while true; do
        (--)        shift; break;;
        (*)
            { setup_setOption2 "$1" "$2" && shift; } || \
-           { echo $"vserver-build: internal error."; exit 1; } >&2
+             panic $"vserver-build: internal error."
            ;;
     esac
     shift
 done
 
-test "$VSERVER_NAME" || {
-    echo $"Name of vserver not specified"
-    exit 1
-} >&2
+test -n "$VSERVER_NAME" ||
+    panic $"Name of vserver not specified"
 
 setup_setDefaults "$VSERVER_NAME"
 
@@ -123,10 +121,6 @@ case x"$method" in
     (xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum)
                . $PKGLIBDIR/vserver-build.$method
                ;;
-    (x)                echo $"No build-method specified" >&2
-               exit 1
-               ;;
-    (*)                echo $"Unknown build-method '$method'" >&2
-               exit 1
-               ;;
+    (x)                panic $"No build-method specified";;
+    (*)                panic $"Unknown build-method '$method'";;
 esac
index 2824292..27fb8d2 100644 (file)
@@ -31,7 +31,7 @@ function initVariables
 {
     base.initVariables
 
-    test "${mirror-unset}" || {
+    test -n "${mirror-unset}" || {
        local aux
        findFile aux "$CONFDIR"/.defaults/apps/debootstrap/mirror ''
        test -z "$aux" || read mirror <"$aux"
index 9a1bb5c..29d8426 100644 (file)
@@ -35,13 +35,13 @@ function rpm.importGPGPubKeys
        done
     done
 
-    test "$pkgs" || return 0
+    test -n "$pkgs" || return 0
     "$_VRPM" "$dst" -- --import "${pkgs[@]}"
 }
 
 function rpm.initVariables
 {
-    test "$WORKAROUND_106057" && \
+    test -n "$WORKAROUND_106057" && \
        RPMDB_PATH=/.rpmdb || \
        RPMDB_PATH=/dev
 
index 2a3241d..431c638 100644 (file)
@@ -126,7 +126,7 @@ function _setup_writeInterface
     _setup_writeSingleOption "$mask"   $d/mask
     _setup_writeSingleOption "$prefix" $d/prefix
 
-    test "$dev" -o "$SETUP_NETDEV" || \
+    test -n "$dev" -o -n "$SETUP_NETDEV" || \
        echo $"No device specified for interface '$idx'; do not forget to set the 'nodev' option" >&2
 }
 
index 41a3a80..ccbd2e1 100755 (executable)
@@ -22,7 +22,7 @@ test -e "$UTIL_VSERVER_VARS" || {
 }
 . "$UTIL_VSERVER_VARS"
 
-test "$MARK" || MARK=default
+test -n "$MARK" || MARK=default
 : ${LOCKFILE:=vservers-$MARK}
 : ${NUMPARALLEL:=6}
 
index 048aef7..4f26737 100644 (file)
@@ -63,7 +63,7 @@ SILENT_OPT=
 
 : ${VSERVER_NAME:=$(basename "$VSERVER_DIR")}
 
-if test -e "$VSERVER_DIR"/noisy -o "$OPTION_VERBOSE"; then
+if test -e "$VSERVER_DIR"/noisy -o -n "$OPTION_VERBOSE"; then
     SILENT_OPT=
 else
     SILENT_OPT='--silent'
@@ -75,7 +75,7 @@ function _generateChbindOptions
     local i
     local bcast=
 
-    test "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
+    test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
 
     local f=$vdir/interfaces/bcast
     getFileValue bcast "$f"
@@ -166,7 +166,7 @@ function getEnterShell
 
     getFileValue ENTER_SHELL "$vdir"/shell "$CONFDIR"/.defaults/shell
     
-    test "$ENTER_SHELL" || {
+    test -n "$ENTER_SHELL" || {
        local i
        for i in "/bin/bash -login" "/bin/sh -l" /bin/csh; do
            set -- $i
@@ -188,7 +188,7 @@ function sendKillSequence
        test -z "$wait" || sleep "$wait"
        
        $_VKILL -c "$ctx" ${1:+-s "$1"} 2>/dev/null || :
-       test "$2" || break
+       test -n "$2" || break
        wait="$2"
        shift 2
     done
@@ -219,8 +219,8 @@ function _generateInitOptions
 
     case x"$INITSTYLE" in
        (xsysv)
-           test "$RUNLEVEL_START" || RUNLEVEL_START=3
-           test "$RUNLEVEL_STOP"  || RUNLEVEL_STOP=6
+           test -n "$RUNLEVEL_START" || RUNLEVEL_START=3
+           test -n "$RUNLEVEL_STOP"  || RUNLEVEL_STOP=6
 
            for i in /etc/init.d/rc /etc/rc.d/rc; do
                test -x "$vdir/vdir/$i" || continue
@@ -266,7 +266,7 @@ function _generateInitOptions
     getFileArray INITCMD_PREPARE    "$cfgdir"/cmd.prepare    || :
 
     
-    test "$OPTION_FORCE_SYNC" -o -e "$cfgdir"/sync || {
+    test -n "$OPTION_FORCE_SYNC" -o -e "$cfgdir"/sync || {
        INITCMD_START_SYNC=()
        INITCMD_STOP_SYNC=()
        _NEED_VSHELPER_SYNC=
@@ -358,7 +358,7 @@ function _generateScheduleOptions
        } <"$f"
     } 2>/dev/null
 
-    test "$prio_bias" || {
+    test -n "$prio_bias" || {
        echo $"Bad content in '$f'; aborting..." >&2
        false
     }
@@ -390,7 +390,7 @@ function _transformMask2Prefix
 {
     local _tm2p_tmp=$2
     
-    test "$_tm2p_tmp" || {
+    test -n "$_tm2p_tmp" || {
        $_MASK2PREFIX "$3" || _tm2p_tmp=$?
     }
 
@@ -441,8 +441,8 @@ function _processSingleInterface
     _getInterfaceValue scope  '' "$iface" "$iface/.."
     _getInterfaceValue mac    '' "$iface"
 
-    test "$ip" || { echo $"Can not read ip for '$iface'"  >&2; return 1; }
-    test "$dev" -o -e "$iface"/nodev || {
+    test -n "$ip" || { echo $"Can not read ip for '$iface'"  >&2; return 1; }
+    test -n "$dev" -o -e "$iface"/nodev || {
        echo $"No device specified for '$iface'" >&2
        return 1;
     }
@@ -475,11 +475,11 @@ function _processSingleInterface
            _addInterfaceCmd IP_ADDR  "$ip${prefix:+/$prefix}" broadcast ${bcast:-+} ${name:+label "$dev:$name"} dev "$dev"
            #_addInterfaceCmd IP_ROUTE "$ip${prefix:+/$prefix}" dev "$dev"
            _addInterfaceCmd IP_LINK  "$dev" $up
-       elif ! test "$ctx"; then
+       elif ! test -n "$ctx"; then
            echo $"Using 'dummy' (indirect) for interface '$dev' requires a fixed context number; dynamic ctx are not supported" >&2
            return 1
        else
-           test "$mac" || _generateMac mac "$(basename $iface)" "$ctx" || return 1
+           test -z "$mac" || _generateMac mac "$(basename $iface)" "$ctx" || return 1
            _addInterfaceCmd MODPROBE dummy "$dev"
            _addInterfaceCmd IP_LINK  dev dummy0 address "$mac"
            _addInterfaceCmd NAMEIF   "$dev" "$mac"
@@ -546,7 +546,7 @@ function enableInterfaces
 
 function disableInterfaces
 {
-    test "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$1"
+    test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$1"
 
     local i=$INTERFACE_CMDS_IDX
     declare -a var
@@ -614,13 +614,13 @@ function prepareStop
 function generateOptions
 {
     _generateInterfaceOptions  "$1"
-    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1" 
+    test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1" 
     _generateNiceCommand       "$1"
     _generateInitOptions       "$1"
     _generateChcontextOptions  "$1"
     _generateScheduleOptions   "$1"
 
-    if test "$_IS_FAKEINIT"; then
+    if test -n "$_IS_FAKEINIT"; then
        CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit )
        OPTS_VCONTEXT_MIGRATE=( "${OPTS_VCONTEXT_MIGRATE[@]}" --initpid --disconnect )
     fi
@@ -666,7 +666,7 @@ function mountVserver
     $_CHROOT_CAT /etc/mtab <"$mtab_src"
     popd >/dev/null
 
-    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
+    test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
 
     test -z "$NAMESPACE_CLEANUP" || isAvoidNamespace "$cfgdir" || \
        $_VNAMESPACE --cleanup
@@ -688,7 +688,7 @@ function _umountVserverInternal
     $_TAC "$fstab" | {
        is_ok=1
        while read src dst tmp; do
-           test "$tmp" || continue
+           test -n "$tmp" || continue
            case x"$src" in
                (x\#*)  continue;;
            esac
@@ -696,7 +696,7 @@ function _umountVserverInternal
        
            "$@" $_EXEC_CD "$dst" $_UMOUNT -lfn . || is_ok=
        done
-       test "$is_ok"
+       test -n "$is_ok"
     }
 }
 
@@ -709,14 +709,14 @@ function umountVserver
     isAvoidNamespace "$cfgdir"    || return 0
     test -e "$cfgdir"/fstab -o \
          -e "$cfgdir"/fstab.local || return 0
-    test "$_HAVE_CHBIND_OPTIONS"  || _generateChbindOptions "$cfgdir"
+    test -n "$_HAVE_CHBIND_OPTIONS"  || _generateChbindOptions "$cfgdir"
     
     pushd "$vdir/" >/dev/null || return 1
        _umountVserverInternal  "$cfgdir"/fstab.local                              || is_ok=
        _umountVserverInternal  "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
     popd >/dev/null           || return 1
 
-    test "$is_ok"
+    test -n "$is_ok"
 }
 
 ## Usage: waitForSync <vserver> <vshelper-fifo-varname>
@@ -731,13 +731,13 @@ function waitForSync
     local cfgdir=$1
     local fifo=$2
     
-    if test "$_NEED_VSHELPER_SYNC"; then
+    if test -n "$_NEED_VSHELPER_SYNC"; then
        $_VSHELPER_SYNC "$fifo" "$VSHELPER_SYNC_TIMEOUT" || \
            warning $"\
 A timeout or other error occured while waiting for the synchronization
 signal from vserver '$VSERVER_NAME'.
 The vserver will be killed nevertheless..."
-    elif test "${#INITCMD_STOP_SYNC[@]}" -ne 0; then
+    elif test -n "${#INITCMD_STOP_SYNC[@]}" -ne 0; then
        "${INITCMD_STOP_SYNC[@]}" || \
            warning $"\
 Stop-synchronization for vserver '$VSERVER_NAME' failed. The vserver
@@ -774,7 +774,7 @@ function execScriptlets
            $start "$i" "$flavor" "$name"
        done
 
-       test -z "$already_handled" -o "$DONT_SKIP_DEFAULTS" || break
+       test -z "$already_handled" -o -n "$DONT_SKIP_DEFAULTS" || break
     done
 }
 
index 1c65eb8..99a123e 100644 (file)
@@ -30,7 +30,7 @@ function cleanup()
     test -z "$startsync_pipe"  || $_RM -f "$startsync_pipe"
     test -z "$is_started"      || { unlock; return 0; }
 
-    if test "$is_configured" -a -z "$is_executed"; then
+    if test -n "$is_configured" -a -z "$is_executed"; then
        warning $"
 An error occured while executing the vserver startup sequence; when
 there are no other messages, it is very likely that the init-script
@@ -42,7 +42,7 @@ Common causes are:
   appending 'true' to this file will help."
     fi
 
-    if test "$is_executed"; then
+    if test -n "$is_executed"; then
        warning $"
 An error occured after executing the vserver startup sequence. This
 means that some processes may exist in the created context and the
@@ -57,7 +57,7 @@ is recommended to fix this."
 Failed to start vserver '$VSERVER_NAME'"
     fi
 
-    test    "$OPTION_DEBUG"    || exec 2>/dev/null >/dev/null
+    test -n "$OPTION_DEBUG"    || exec 2>/dev/null >/dev/null
     test -z "$is_mounted"      || umountVserver     "$VSERVER_DIR" || :
     test -z "$have_interfaces" || disableInterfaces "$VSERVER_DIR" || :
 
@@ -109,7 +109,7 @@ if $_VSERVER_INFO - FEATURE migrate; then
     $_VCONTEXT   --migrate-self --endsetup --chroot $SILENT_OPT "${OPTS_VCONTEXT_MIGRATE[@]}" -- \
     "${INITCMD_START[@]}"
 else
-    if test "$_IS_FAKEINIT"; then
+    if test -n "$_IS_FAKEINIT"; then
        startsync_pipe=$($_MKTEMP /tmp/vserver-start.XXXXXX)
        $_RM -f "$startsync_pipe"
        $_MKFIFO -m600 "$startsync_pipe"        ## safe, since mkfifo does not follow symlinks
index 3b4153b..8530927 100644 (file)
@@ -20,7 +20,7 @@ lock "$LOCKDIR"/vserver."$($_VSERVER_INFO "$VSERVER_DIR" CANONIFY)".startup
 
 if ! isVserverRunning "$VSERVER_DIR" S_CONTEXT; then
     warning $"vserver '$VSERVER_NAME' is not running" >&2
-    test "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
+    test -n "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
     umountVserver     "$VSERVER_DIR" || :
     disableInterfaces "$VSERVER_DIR" || :
     unlock
@@ -56,7 +56,7 @@ cd "$VSERVER_DIR"/vdir/
 test -z "$OPTION_DEFAULTTTY" || setDefaultTTY "$VSERVER_DIR"
 
 fail=
-if test "$_IS_FAKEINIT" && \
+if test -n "$_IS_FAKEINIT" && \
    $_VSERVER_INFO - FEATURE vkill && \
    initpid=$($_VSERVER_INFO "$S_CONTEXT" INITPID 2>/dev/null); then
     $_VKILL -s INT -- "$initpid" || fail=1
@@ -75,7 +75,7 @@ else
     "${INITCMD_STOP[@]}" || fail=1
 fi
 
-test "$fail" || waitForSync "$VSERVER_DIR" "$sync_fifo"
+test -n "$fail" || waitForSync "$VSERVER_DIR" "$sync_fifo"
 
 vshelper.doDestroy "$VSERVER_DIR" "$S_CONTEXT"
 sendKillSequence   "$S_CONTEXT" "${INITKILL_SEQ[@]}"
index 8fb9bb5..1d727e2 100755 (executable)
@@ -73,7 +73,7 @@ function doInternalMethod
            
        (sync)
            local f=${METHOD_ARGS[0]}
-           test "$f" ||
+           test -n "$f" ||
                panic $"Insufficent arguments for method '$method' and vserver '$VSERVER'"
 
            test -p "$f" ||
@@ -86,7 +86,7 @@ function doInternalMethod
            local script
            findObject -x script "$CONFDIR"/.defaults/apps/vshelper-methods/"$method" "$PKGLIBDIR"/vshelper-methods/"$method" ''
            
-           test '$script' || {
+           test -n '$script' || {
                warning $"No handler for internal method '$method' found"
                exit 1
            }
index a2d497b..46a4b26 100755 (executable)
@@ -95,13 +95,13 @@ res=255
 for i in "${vservers[@]}"; do
     cnt=$[ cnt + 1 ]
 
-    test "$is_quiet" || {
+    test -n "$is_quiet" || {
        colorize bold echo -n "$title: operating on vserver "
        colorize bold colorize emph echo "$i"
        xtermTitle "$title: operating on vserver '$i'  [$cnt/${#vservers[@]}]"
     }
 
-    if test "$VSOMETHING_PKGMGMT"; then
+    if test -n "$VSOMETHING_PKGMGMT"; then
        if pkgmgmt.isInternal "$i"; then
            $_VSERVER "$i" exec "$cmd" "$@"
        else
@@ -114,12 +114,12 @@ for i in "${vservers[@]}"; do
        
     res=$?
 
-    test $res -eq 0 -o "$is_quiet" || {
+    test $res -eq 0 -o -n "$is_quiet" || {
        colorize error echo -n $"$title failed on vserver '$i' with errorcode $res"
        echo
     }
        
-    test "$is_quiet" || echo
+    test -n "$is_quiet" || echo
 done
 
 test "$cnt" -ge 0 || warning $"No vservers specified"