zsh-users
 help / color / mirror / code / Atom feed
From: Zach Riggle <zachriggle@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Command wrappers in $PATH, and re-executing the "correct" value
Date: Sat, 21 May 2022 01:28:40 -0500	[thread overview]
Message-ID: <CAMP9c5k0hkXJJjKHGbSzAZ43eKVdGzvTKGYxtZdaXu9EPU-ZvQ@mail.gmail.com> (raw)

[-- 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 --]

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21  6:28 Zach Riggle [this message]
2022-05-21  7:12 ` Roman Perepelitsa
2022-05-21  7:20   ` Mikael Magnusson
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=CAMP9c5k0hkXJJjKHGbSzAZ43eKVdGzvTKGYxtZdaXu9EPU-ZvQ@mail.gmail.com \
    --to=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).