zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Lawrence Velázquez" <vq@larryv.me>
Cc: Ray Andrews <rayandrews@eastlink.ca>, Zsh Users <zsh-users@zsh.org>
Subject: Re: xargs with zsh function
Date: Tue, 19 Jan 2021 12:31:32 -0800	[thread overview]
Message-ID: <CAH+w=7aGY-2SwgOWjFjSU9Kr0KR=Zu41fqKn32zM-jzF1tt0OQ@mail.gmail.com> (raw)
In-Reply-To: <8868DABE-1D18-400F-A8F7-31450A892F0D@larryv.me>

[-- Attachment #1: Type: text/plain, Size: 644 bytes --]

On Tue, Jan 19, 2021 at 9:52 AM Lawrence Velázquez <vq@larryv.me> wrote:
>
> > On Jan 19, 2021, at 9:30 AM, Ray Andrews <rayandrews@eastlink.ca> wrote:
> >
> > Anyway I'd like zargs to work within my environment as it is.
>
> To establish a known configuration, zargs resets nearly all zsh options for the duration of its execution. Your function should do likewise.

The latter is always good practice, but it does raise the point that
zargs is less useful if you aren't using something close to zsh mode.

I'm still pondering if there's a better way to do this, but in the meantime ...

(attached to avoid gmail line wrapping)

[-- Attachment #2: zargs_patch.txt --]
[-- Type: text/plain, Size: 758 bytes --]

diff --git a/Functions/Misc/zargs b/Functions/Misc/zargs
index 28ebca78f..49c177fb6 100644
--- a/Functions/Misc/zargs
+++ b/Functions/Misc/zargs
@@ -70,6 +70,15 @@
 #   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/param
+then
+  emulate zsh -c "_zarun() { options=( ${(j: :kv)options[@]} )"' eval "$@" }'
+else
+  # Warning?
+  _zarun() { eval "$@" }
+fi
+
 emulate -L zsh || return 1
 local -a opts eof n s l P i
 
@@ -186,7 +195,7 @@ local execute='
     elif (( $opts[(I)-(-verbose|t)] ))
     then print -u2 -r -- "$call"
     fi
-    eval "{
+    _zarun "{
        \"\${(@)call}\"
     } $bg"'
 local ret=0 analyze='

  parent reply	other threads:[~2021-01-19 20:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17 23:12 Ray Andrews
2021-01-18  3:10 ` Bart Schaefer
2021-01-18 22:14   ` Ray Andrews
2021-01-18 23:09     ` Bart Schaefer
2021-01-19  5:18       ` Ray Andrews
2021-01-19 14:30         ` Ray Andrews
2021-01-19 17:52           ` Lawrence Velázquez
2021-01-19 20:27             ` Ray Andrews
2021-01-19 21:39               ` Bart Schaefer
2021-01-19 23:48                 ` Ray Andrews
2021-01-20  1:05                 ` Ray Andrews
2021-01-20 18:25                   ` Ray Andrews
2021-01-21  5:52                     ` Bart Schaefer
2021-01-21 19:55                       ` Ray Andrews
2021-01-21 21:50                         ` Bart Schaefer
2021-01-21 23:20                           ` Ray Andrews
2021-01-19 20:31             ` Bart Schaefer [this message]
2021-01-19 20:59               ` Ray Andrews
2021-01-20 16:27   ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7aGY-2SwgOWjFjSU9Kr0KR=Zu41fqKn32zM-jzF1tt0OQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=rayandrews@eastlink.ca \
    --cc=vq@larryv.me \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).