about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@ipost.com>2021-01-23 13:25:24 -0800
committerBart Schaefer <schaefer@ipost.com>2021-01-23 13:25:24 -0800
commitb374f7b31871358dc87ffcf3adfad099f7d5c6c8 (patch)
tree43d45f7793eee36a1212c9637ee9f3cc583a6aeb
parent6e20f0e3d1b9062d6e26df5c565e122888cf22ae (diff)
downloadzsh-b374f7b31871358dc87ffcf3adfad099f7d5c6c8.tar.gz
zsh-b374f7b31871358dc87ffcf3adfad099f7d5c6c8.tar.xz
zsh-b374f7b31871358dc87ffcf3adfad099f7d5c6c8.zip
users/26406: preserve caller setopts in zargs
-rw-r--r--ChangeLog4
-rw-r--r--Functions/Misc/zargs17
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4cf94b1f2..d8c6d0e94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2021-01-23  Bart Schaefer  <schaefer@zsh.org>
+
+	* users/26406: Functions/Misc/zargs: preserve caller setopts
+
 2021-01-20  Jun-ichi Takimoto  <takimoto-j@kba.biglobe.ne.jp>
 
 	* 47849: Test/E01options.ztst, Test/V08zpty.ztst,
diff --git a/Functions/Misc/zargs b/Functions/Misc/zargs
index 28ebca78f..ecd69f7e4 100644
--- a/Functions/Misc/zargs
+++ b/Functions/Misc/zargs
@@ -70,6 +70,19 @@
 #   this behavior, as do -l/-L, but when -i/-I appear anywhere then -l/-L
 #   are ignored (forced to 1).
 
+# First, capture the current setopts as "sticky emulation"
+if zmodload zsh/parameter
+then
+  emulate $(emulate -l) -c "\
+    _zarun() {
+      options=( ${(j: :kv)options[@]} monitor off zle off )"'
+      eval "$@"
+    }'
+else
+  # Warning?
+  emulate $(emulate -l) -c '_zarun() { eval "$@" }'
+fi
+
 emulate -L zsh || return 1
 local -a opts eof n s l P i
 
@@ -186,8 +199,8 @@ local execute='
     elif (( $opts[(I)-(-verbose|t)] ))
     then print -u2 -r -- "$call"
     fi
-    eval "{
-	\"\${(@)call}\"
+    _zarun "{
+	\"\${call[@]}\"
     } $bg"'
 local ret=0 analyze='
     case $? in