On 23/11/2024 09:14, Simon Tatham wrote:
Simon Tatham <ana...@pobox.com> wrote:
I think it would be useful if 'env' had an option which would cause it
to treat its COMMAND argument as _necessarily_ a pathname to an
executable file, rather than the usual semantics of considering it to be
either that or a command to search for on PATH.

Rob Landley wrote:
When you care about that you do ./filename and the ./ is an explicit
path meaning "in the current directory".

But the COMMAND might not _be_ in the current directory. The feature I'm
suggesting would be usable if COMMAND is _either_ of a cwd-relative path
_or_ an absolute path.

Prefixing "./" makes a cwd-relative path work fine, as you say. But it
causes an absolute path to _stop_ working. Consider the commands

   env --nopath foo
   env --nopath bar/foo
   env --nopath /opt/quux/bin/foo

If one replaces the nonexistent "env --nopath" with a prefix "./" as you
suggest, then we get

   ./foo
   ./bar/foo
   .//opt/quux/bin/foo

All these boil down to you want to pass the actual path
rather than lookup a name in $PATH.
This can be achieved simply with: env $(realpath -ms "$path")

cheers,
Pádraig.

Reply via email to