summary refs log tree commit diff
path: root/Test/B07emulate.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-09-11 10:12:17 +0100
committerPeter Stephenson <pws@zsh.org>2017-09-11 10:12:17 +0100
commit2ef3dff65a9fc0bc69446374473ad08e6fff4755 (patch)
treef3b00a11df3ef3d6fc43bb12c2d16a133d042e48 /Test/B07emulate.ztst
parentc9df6bc8d46415e270273777c80025948762e897 (diff)
downloadzsh-2ef3dff65a9fc0bc69446374473ad08e6fff4755.tar.gz
zsh-2ef3dff65a9fc0bc69446374473ad08e6fff4755.tar.xz
zsh-2ef3dff65a9fc0bc69446374473ad08e6fff4755.zip
41668: New --emulate option on invocation.
This sets the shell emulation mode similarly to ARGV0=... which
doesn't work from other shells.

Note that this gives more comprehensive emulation than running
emulate within the shell.
Diffstat (limited to 'Test/B07emulate.ztst')
-rw-r--r--Test/B07emulate.ztst25
1 files changed, 25 insertions, 0 deletions
diff --git a/Test/B07emulate.ztst b/Test/B07emulate.ztst
index 2de097e25..7b1592fa9 100644
--- a/Test/B07emulate.ztst
+++ b/Test/B07emulate.ztst
@@ -251,3 +251,28 @@
  emulate sh -c '[[ a == a ]]'
 0:regression test for POSIX_ALIASES reserved words
 F:Some reserved tokens are handled in alias expansion
+
+ for mode in ksh bash zsh; do
+   $ZTST_testdir/../Src/zsh --emulate $mode -f -c 'emulate'
+ done
+0:--emulate option
+>ksh
+>sh
+>zsh
+
+ $ZTST_testdir/../Src/zsh -f --emulate sh
+1:--emulate must be first
+*?*: --emulate: must precede other options
+
+ $ZTST_testdir/../Src/zsh --emulate
+1:--emulate needs an argument
+*?*: --emulate: argument required
+
+ for opt in shwordsplit noshwordsplit; do
+   $ZTST_testdir/../Src/zsh --emulate sh -f -o $opt -c '
+     [[ -o shwordsplit ]] && echo yes || echo no
+   '
+ done
+0:--emulate followed by other options
+>yes
+>no