coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature suggestion: env --nopath


From: Pádraig Brady
Subject: Re: Feature suggestion: env --nopath
Date: Sat, 23 Nov 2024 15:04:58 +0000
User-agent: Mozilla Thunderbird Beta

On 23/11/2024 09:14, Simon Tatham wrote:
Simon Tatham <anakin@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

[Prev in Thread] Current Thread [Next in Thread]