about summary refs log tree commit diff
path: root/Test/E01options.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-04-15 09:44:19 +0100
committerPeter Stephenson <pws@zsh.org>2015-04-15 09:44:19 +0100
commita2c579050fbf40eb9192f043e901e6b2eff3ab50 (patch)
tree320c38cb5e98627b020da1f1ca9be387641d7ee2 /Test/E01options.ztst
parent741b0bd97f6ddbd69fb2fa1dbbf6604a51488d82 (diff)
downloadzsh-a2c579050fbf40eb9192f043e901e6b2eff3ab50.tar.gz
zsh-a2c579050fbf40eb9192f043e901e6b2eff3ab50.tar.xz
zsh-a2c579050fbf40eb9192f043e901e6b2eff3ab50.zip
34887: Fix POSIX_BUILTINS with assignment.
In the form
  var=val command special-builtin-or-func
the var is restored after execution, unlike the case where "command"
is absent.

Clear up case in code that handles this.

Add tests.
Diffstat (limited to 'Test/E01options.ztst')
-rw-r--r--Test/E01options.ztst13
1 files changed, 13 insertions, 0 deletions
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 32135344f..5c453c80b 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -783,6 +783,19 @@
 >print is a shell builtin
 ?(eval):8: command not found: print
 
+  # With non-special command: original value restored
+  # With special builtin: new value kept
+  # With special builtin preceeded by "command": original value restored.
+  (setopt posixbuiltins
+  FOO=val0
+  FOO=val1 true; echo $FOO
+  FOO=val2 times 1>/dev/null 2>&1; echo $FOO
+  FOO=val3 command times 1>/dev/null 2>&1; echo $FOO)
+0:POSIX_BUILTINS and restoring variables
+>val0
+>val2
+>val2
+
 # PRINTEXITVALUE only works if shell input is coming from standard input.
 # Goodness only knows why.
   $ZTST_testdir/../Src/zsh -f <<<'