zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Zach Riggle <zachriggle@gmail.com>, Zsh Users <zsh-users@zsh.org>
Subject: Re: Command wrappers in $PATH, and re-executing the "correct" value
Date: Sat, 21 May 2022 09:20:52 +0200	[thread overview]
Message-ID: <CAHYJk3Rz2Sqa+ZczcE1cxJGm0Yew4OskHJ+fxwGj=hTWxHc8sQ@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMoumEB6iUramyMQvn0b6ApMgXjGsNd4eH0zuX_eFpAHFA@mail.gmail.com>

On 5/21/22, Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote:
> On Sat, May 21, 2022 at 8:30 AM Zach Riggle <zachriggle@gmail.com> wrote:
>>
>> I find that very frequently I write a wrapper for some CLI tool, say
>> "foobar".
>>
>> I have a wrapper script ~/bin/foobar, which will be invoked for the
>> command "foobar".  What my wrapper script does is immaterial, but
>> it eventually executes the /usr/local/bin/foobar with some set of
>> arguments.
>
> You can try this:
>
>     #!/usr/bin/zsh
>     #
>     # usage: next-command <command> [arg]..
>
>     path=(${path:#${commands[$1]:h}}) "$@"

I'm using this in mine (wrapper script of same name as target binary),
path[(R)$0:h]=() exec $0:t "$@"

-- 
Mikael Magnusson


  reply	other threads:[~2022-05-21  7:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21  6:28 Zach Riggle
2022-05-21  7:12 ` Roman Perepelitsa
2022-05-21  7:20   ` Mikael Magnusson [this message]
2022-05-21  7:31     ` Roman Perepelitsa

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='CAHYJk3Rz2Sqa+ZczcE1cxJGm0Yew4OskHJ+fxwGj=hTWxHc8sQ@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=zachriggle@gmail.com \
    --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).