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

Re: Future of /usr/bin/which in Debian?



On 2021-09-21 at 16:16, Michael Stone wrote:

> On Tue, Sep 21, 2021 at 09:00:52AM +0100, Jonathan Dowland wrote:
> 
>> On Mon, Sep 20, 2021 at 11:02:49AM -0400, Michael Stone wrote:
>> 
>>> It seems to install to /usr/bin/which.gnu, implying that you
>>> could upload /usr/bin/which.bsd if you so desire; what's the
>>> issue?
>> 
>> I think we should have just one which implementation in the
>> archive. We should (have) pick(ed) the best one for Debian. I
>> believe (perhaps unfairly... I'd love to be proven wrong) that the
>> GNU implementation was uploaded very quickly, without the BSD
>> implementation being considered. Perhaps the GNU one is the best
>> fit for our needs. It would have been nice to see that there was an
>> evaluation.
> 
> I think it doesn't matter how many which implementations are in
> debian. If you want something with specific portable semantics, just
> use command -v.

I think I've seen that suggested a lot as an alternative for 'which',
but it doesn't seem to be comparably reliable in all contexts.

The primary issue I've run across to date is with aliases.

For example, on my computer as I type this:

$ which ls
/usr/bin/ls
$ command -v ls
alias ls='ls -N --color=auto'
$ $(which ls) /
bin   home            lib32       media  pulse  srv  var
boot  initrd.img      lib64       mnt    root   sys  vmlinuz
dev   initrd.img.old  libx32      opt    run    tmp  vmlinuz.old
etc   lib             lost+found  proc   sbin   usr
$ $(command -v ls) /
bash: alias: -N: not found
bash: alias: /: not found

And then 'ls' is broken in that shell session; I haven't yet found a way
to get it working again, short of exiting and re-launching the shell.
(Though I also haven't tried *terribly* hard.)

This seems to demonstrate that you can't safely just use 'command -v'
wherever you would otherwise use 'which'.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: