Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Command wrappers in $PATH, and re-executing the "correct" value
- X-seq: zsh-users 27778
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Zach Riggle <zachriggle@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Command wrappers in $PATH, and re-executing the "correct" value
- Date: Sat, 21 May 2022 09:20:52 +0200
- Archived-at: <https://zsh.org/users/27778>
- In-reply-to: <CAN=4vMoumEB6iUramyMQvn0b6ApMgXjGsNd4eH0zuX_eFpAHFA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5k0hkXJJjKHGbSzAZ43eKVdGzvTKGYxtZdaXu9EPU-ZvQ@mail.gmail.com> <CAN=4vMoumEB6iUramyMQvn0b6ApMgXjGsNd4eH0zuX_eFpAHFA@mail.gmail.com>
On 5/21/22, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> On Sat, May 21, 2022 at 8:30 AM Zach Riggle <zachriggle@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author