bug-gawk
[Top][All Lists]
Advanced

[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



reply via email to

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