Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: xargs with zsh function

> Not knowing diff, I copied Bart's changes in by hand and got:
>      failed to load module: zsh/param

Yeah, I pasted the wrong diff into the file I then attached.  Sorry about that.

In the meantime I've made some improvements, including correcting this:

>      _zarun: can't change option: zle

It should now preserve option settings as much as possible.  However,
the function itself can't autoload with "sh" emulation in effect; if
you want to use this where zsh is acting as /bin/sh, you need to use:
  emulate zsh -c 'autoload zargs'

Since Ray asked:  Apply this with
 patch -p1 Functions/Misc/zargs < zargs_patch2.txt
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
+  emulate $(emulate -l) -c "\
+    _zarun() {
+      options=( ${(j: :kv)options[@]} monitor off zle off )"'
+      eval "$@"
+    }'
+  # Warning?
+  emulate $(emulate -l) -c '_zarun() { eval "$@" }'
 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"
-    eval "{
-	\"\${(@)call}\"
+    _zarun "{
+	\"\${call[@]}\"
     } $bg"'
 local ret=0 analyze='
     case $? in

Messages sorted by: Reverse Date, Date, Thread, Author