]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
use which instead of type
authorDwight Engen <dwight.engen@oracle.com>
Tue, 22 Jan 2013 20:59:44 +0000 (15:59 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 22 Jan 2013 22:51:59 +0000 (17:51 -0500)
This is for consistency with the rest of lxc, and also because type checks for
shell builtins, a behavior that we do not want in these cases. Ensure stderr
for which is redirected to /dev/null also.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxc-clone.in
src/lxc/lxc-create.in
src/lxc/lxc-shutdown.in
templates/lxc-busybox.in
templates/lxc-ubuntu.in

index 22f0376e4418726153e8b39d05f978ebff3bcbc3..76fc2f6e527cc48d92febdd21f9d142d66d0e2a6 100644 (file)
@@ -197,7 +197,7 @@ lxc-info -n $lxc_orig --state-is RUNNING || container_running=False
 
 sed -i '/lxc.rootfs/d' $lxc_path/$lxc_new/config
 if [ -b $oldroot ]; then
-    which vgscan >/dev/null || { echo "$(basename $0): lvm is not installed" >&2; false; }
+    which vgscan >/dev/null 2>&1 || { echo "$(basename $0): lvm is not installed" >&2; false; }
     lvdisplay $oldroot > /dev/null 2>&1 || { echo "$(basename $0): non-lvm blockdev cloning is not supported" >&2; false; }
     lvm=TRUE
     # ok, create a snapshot of the lvm device
index 5cd9fdba5d0f4ab793ec241112cd09a4448966e1..9348d87e4a10354f450736c0b1ebf7b8d66810a5 100644 (file)
@@ -222,7 +222,7 @@ if [ "$backingstore" = "_unset" ] || [ "$backingstore" = "btrfs" ]; then
 fi
 
 if [ "$backingstore" = "lvm" ]; then
-    which vgscan > /dev/null
+    which vgscan > /dev/null 2>&1
     if [ $? -ne 0 ]; then
         echo "$(basename $0): vgscan not found (is lvm2 installed?)" >&2
         exit 1
index a033b1075b5185aa3794eee6cb6225a0e960c703..fdcade2a419d4d84d99522f8007349c63694dc81 100644 (file)
@@ -108,8 +108,8 @@ if [ "$(id -u)" != "0" ]; then
    exit 1
 fi
 
-which lxc-info > /dev/null || { echo "lxc-info not found."; exit 1; }
-which lxc-wait > /dev/null || { echo "lxc-wait not found."; exit 1; }
+which lxc-info > /dev/null 2>&1 || { echo "lxc-info not found."; exit 1; }
+which lxc-wait > /dev/null 2>&1 || { echo "lxc-wait not found."; exit 1; }
 
 pid=`lxc-info -n $lxc_name -p 2>/dev/null | awk '{ print $2 }'`
 if [ "$pid" = "-1" ]; then
index 439657f87bce242ad3bf18cdad06f4dbfd040f44..cb425ecf8d08a24b17d3dd6e472a05ea102573b3 100644 (file)
@@ -153,7 +153,7 @@ configure_busybox()
 {
     rootfs=$1
 
-    type busybox >/dev/null
+    which busybox >/dev/null 2>&1
 
     if [ $? -ne 0 ]; then
         echo "busybox executable is not accessible"
@@ -194,7 +194,7 @@ configure_busybox()
 
 
     # add ssh functionality if dropbear package available on host
-    type dropbear >/dev/null
+    which dropbear >/dev/null 2>&1
     if [ $? -eq 0 ]; then
         # copy dropbear binary
         cp $(which dropbear) $rootfs/usr/sbin
index 0ed8808c76167ca98d21cbee3db943c874666e43..a2fc95201c46227418b4bf87e8bb7ccbcfe87a2c 100644 (file)
@@ -609,7 +609,7 @@ arch=$(arch)
 # Code taken from debootstrap
 if [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture >/dev/null 2>&1; then
     arch=`/usr/bin/dpkg --print-architecture`
-elif type udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then
+elif which udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then
     arch=`/usr/bin/udpkg --print-architecture`
 else
     arch=$(arch)
@@ -666,11 +666,7 @@ if [ $hostarch = "i386" -a $arch = "amd64" ]; then
     exit 1
 fi
 
-type debootstrap
-if [ $? -ne 0 ]; then
-    echo "'debootstrap' command is missing"
-    exit 1
-fi
+which debootstrap >/dev/null 2>&1 || { echo "'debootstrap' command is missing" >&2; false; }
 
 if [ -z "$path" ]; then
     echo "'path' parameter is required"