zsh-users
 help / color / mirror / code / Atom feed
* Command wrappers in $PATH, and re-executing the "correct" value
@ 2022-05-21  6:28 Zach Riggle
  2022-05-21  7:12 ` Roman Perepelitsa
  0 siblings, 1 reply; 4+ messages in thread
From: Zach Riggle @ 2022-05-21  6:28 UTC (permalink / raw)
  To: Zsh Users

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

I find that very frequently I write a wrapper for some CLI tool, say
"foobar".

Let's say lives at e.g. /usr/local/bin/foobar, and $path is ( ... ~/bin ...
/usr/local/bin ).

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.

As best I can tell, there are three ways to make this work neatly:

   - Implement "my" foobar as a function, and use "command foobar"
      - How do I make this an autoloadable module, which doesn't need to
      use e.g.
      "autoload foobar && foobar"
   - Remove ~/bin from $path, and add it to the end
      - This might break other things where system binaries take over
   - Some cool tricks with /usr/bin/env and such I haven't thought of

I've already adopted autoloadable functions via $fpath and using "command
foobar" inside the function, but I was curious if there's another way.  I
expect that removing ${0:h} and ${0:A:h} from $path are the most obvious
answers, but I didn't know if there's anything easier.

*Zach Riggle*

[-- Attachment #2: Type: text/html, Size: 1535 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-21  7:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-21  6:28 Command wrappers in $PATH, and re-executing the "correct" value Zach Riggle
2022-05-21  7:12 ` Roman Perepelitsa
2022-05-21  7:20   ` Mikael Magnusson
2022-05-21  7:31     ` Roman Perepelitsa

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).