commit cecf7ec16ba2637709ecab720a8fd190461f1577
parent 4f5ae8cc592b947f0674fc849a2fab2df422b966
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun, 11 May 2014 16:56:38 +0200
Fixing the argument handling with symlink support.
Diffstat:
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/bin/ns-chroot b/bin/ns-chroot
@@ -6,14 +6,14 @@ dounprepare=0
 if [ "$basen" != "ns-chroot" ];
 then
 	nsrootn="$basen"
-	[ "$1" = "-u" ] && dounprepare=1 && shift 1
+	[ $# -gt 1 ] && [ "$1" = "-u" ] && dounprepare=1 && shift 1
 else
 	if [ $# -lt 1 ];
 	then
 		printf "usage: %s [-u] ns [cmd]\n" "$(basename $0)" >&2
 		exit 1
 	fi
-	[ "$1" = "-u" ] && dounprepare=1 && shift 1
+	[ $# -gt 1 ] && [ "$1" = "-u" ] && dounprepare=1 && shift 1
 
 	nsrootn="$1"
 	shift 1
@@ -37,14 +37,12 @@ then
 else
 	cmd="/bin/sh"
 fi
-[ $# -gt 1 ] && cmd="$2" && shift 1
-shift 1
+[ $# -gt 0 ] && cmd="$1" && shift 1
 
 ns-prepare "$nsroot"
 [ $? -gt 0 ] && exit 1
 
 export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
-args="$@"
 if [ ! -d "${nsroot}${curdir}" ];
 then
 	capchroot "$nsroot" $cmd -- "$@"