summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-05-27 15:56:13 +0000
committerjilles <jilles@FreeBSD.org>2011-05-27 15:56:13 +0000
commit543f63b8dc758a4508506526535f62954136bc87 (patch)
treebb8a5ce42369db48f8daa5a5f00c3f734eebf451 /tools
parentb41dc3debc7c84bd2fac07d5b920c500658a9600 (diff)
downloadFreeBSD-src-543f63b8dc758a4508506526535f62954136bc87.zip
FreeBSD-src-543f63b8dc758a4508506526535f62954136bc87.tar.gz
sh: Fix unquoted $@/$* if IFS=''.
If IFS is null, unquoted $@/$* should still expand to separate words. This differs from quoted $@ (which does not depend on IFS) in that pathname generation is performed and empty words are removed.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/expansion/ifs4.039
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/ifs4.0 b/tools/regression/bin/sh/expansion/ifs4.0
new file mode 100644
index 0000000..5b896a2
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/ifs4.0
@@ -0,0 +1,39 @@
+# $FreeBSD$
+
+c=: e= s=' '
+failures=''
+ok=''
+
+check_result() {
+ if [ "x$2" = "x$3" ]; then
+ ok=x$ok
+ else
+ failures=x$failures
+ echo "For $1, expected $3 actual $2"
+ fi
+}
+
+IFS='
+'
+set -- a b '' c
+set -- $@
+check_result 'set -- $@' "($#)($1)($2)($3)($4)" "(3)(a)(b)(c)()"
+
+IFS=''
+set -- a b '' c
+set -- $@
+check_result 'set -- $@' "($#)($1)($2)($3)($4)" "(3)(a)(b)(c)()"
+
+set -- a b '' c
+set -- $*
+check_result 'set -- $*' "($#)($1)($2)($3)($4)" "(3)(a)(b)(c)()"
+
+set -- a b '' c
+set -- "$@"
+check_result 'set -- "$@"' "($#)($1)($2)($3)($4)" "(4)(a)(b)()(c)"
+
+set -- a b '' c
+set -- "$*"
+check_result 'set -- "$*"' "($#)($1)($2)($3)($4)" "(1)(abc)()()()"
+
+test "x$failures" = x
OpenPOWER on IntegriCloud