summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2017-02-20 13:20:14 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2017-02-20 13:26:49 -0800
commit574933e5a0566581155b81009ca8ef4c25f4a3e4 (patch)
tree56711f4a01265711c41e7c1d453a5c3b4b368544 /Test
parentb3c186028e8c13f9bc7afd0bd21d769874759c27 (diff)
downloadzsh-574933e5a0566581155b81009ca8ef4c25f4a3e4.tar.gz
zsh-574933e5a0566581155b81009ca8ef4c25f4a3e4.tar.xz
zsh-574933e5a0566581155b81009ca8ef4c25f4a3e4.zip
40565 (tweaked): test cases for assigning array to scalar with various combinations of SHWORDSPLIT and IFS
Diffstat (limited to 'Test')
-rw-r--r--Test/D04parameter.ztst80
1 files changed, 80 insertions, 0 deletions
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 9128c3c38..fba95cc3a 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2056,3 +2056,83 @@
 0:Regression: "-" became Dash in workers/37689, breaking ~- expansion
 *>*
 F:We do not care what $OLDPWD is, as long as it doesn't cause an error
+
+  (
+  set -- one 'two three' four
+  for ifs in default null unset; do
+    for wordsplit in native sh; do
+      print -r -- "--- $ifs IFS, $wordsplit splitting ---"
+      case $ifs in
+      default) IFS=$' \t\n\00' ;;
+      null)    IFS= ;;
+      unset)   unset -v IFS ;;
+      esac
+      case $wordsplit in
+      native)  unsetopt shwordsplit ;;
+      sh)      setopt shwordsplit ;;
+      esac
+      for testcmd in 'var=$@' 'var=$*' 'var="$@"' 'var="$*"'; do
+	print -r -- "> $testcmd"
+        eval "$testcmd"
+	printf '[%s]\n' "${var[@]}"
+      done
+    done
+  done
+  )
+0:Assigning $@, $*, "$@", "$*" to var with various shwordsplit/IFS settings
+>--- default IFS, native splitting ---
+>> var=$@
+>[one two three four]
+>> var=$*
+>[one two three four]
+>> var="$@"
+>[one two three four]
+>> var="$*"
+>[one two three four]
+>--- default IFS, sh splitting ---
+>> var=$@
+>[one two three four]
+>> var=$*
+>[one two three four]
+>> var="$@"
+>[one two three four]
+>> var="$*"
+>[one two three four]
+>--- null IFS, native splitting ---
+>> var=$@
+>[onetwo threefour]
+>> var=$*
+>[onetwo threefour]
+>> var="$@"
+>[onetwo threefour]
+>> var="$*"
+>[onetwo threefour]
+>--- null IFS, sh splitting ---
+>> var=$@
+>[onetwo threefour]
+>> var=$*
+>[onetwo threefour]
+>> var="$@"
+>[onetwo threefour]
+>> var="$*"
+>[onetwo threefour]
+>--- unset IFS, native splitting ---
+>> var=$@
+>[one two three four]
+>> var=$*
+>[one two three four]
+>> var="$@"
+>[one two three four]
+>> var="$*"
+>[one two three four]
+>--- unset IFS, sh splitting ---
+>> var=$@
+>[one two three four]
+>> var=$*
+>[one two three four]
+>> var="$@"
+>[one two three four]
+>> var="$*"
+>[one two three four]
+F:As of this writing, var=$@ and var="$@" with null IFS have unspecified
+F:behavior, see http://austingroupbugs.net/view.php?id=888