[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no exit status available when a command doesn't exist or fails in pi
From: |
Bob Proulx |
Subject: |
Re: no exit status available when a command doesn't exist or fails in pipe to grep |
Date: |
Mon, 6 Sep 2021 17:42:28 -0600 |
Nelson H. F. Beebe wrote:
> However, in Debian 11 updates, I recently got this report:
>
> /usr/bin/which: this version of `which' is deprecated;
> use `command -v' in scripts instead.
>
> Here is an example of its use:
>
> % /usr/bin/command -v garbage || echo MISSING garbage
> MISSING garbage
>
> I find "command" in DragonFlyBSD, FreeBSD, most Linux, and Solaris
> family, but it is not available in recent GnuiOS, Gnewsense,
> GoboLinux, GNU/Hurd, NetBSD and OpenBSD systems.
The /bin/sh "command -v" builtin appears to me to be a part of POSIX
now. I am unclear when this change became effective. It had not been
at one time.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
So if one has access to a POSIX sh of a current vintage on a system
then one can use the sh builtin version on a standards conforming
system. For example I tested NetBSD just now and the /bin/sh there
did support the use of "command -v". Also documented as such in the
man page for sh.
netbsd$ /bin/sh -c 'command -v cat'
/bin/cat
Bob
- no exit status available when a command doesn't exist or fails in pipe to grep, ED MORTON, 2021/09/06
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, arnold, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Andrew J. Schorr, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, arnold, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, arnold, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Neil R. Ormos, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Andrew J. Schorr, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/09