On Wed, Aug 18, 2021 at 13:28:14 +0900, Norbert Preining wrote: ... > but being noisy about it on any invocation, **without** providing > an alternative is a no go ... > Please use NEWS, or whatever other channels, and above all, **provide > information on a replacement!**
I checked 'man which' when I saw the text; the DEPRECATION section hints
at the replacements, though it could more directly suggest 'command -v'.
That appears equivalent for any use with a single argument, when special
printing of a shell alias, function, or builtin is acceptable. Notably,
it would handle everything I saw in /var/lib/dpkg/info, where I observed
3 patterns of use:
* direct, as in console-setup.config:
if which uname >/dev/null; then
* redundantly combined with test -x, as in libssl1.1:amd64.postinst:
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
* used with an "invalid" argument, as in libreoffice-common.postrm:
if [ -x "`which ucfr --force 2>/dev/null`" ]; then
All are simply checking whether a command is present.
How about providing the following text?
The 'which' utility will be removed in the future. Shell scripts often use
it to check whether a command is available. A more standard way to do this
is with 'command -v'; for example:
if command -v update-icon-caches >/dev/null; then
update-icon-caches /usr/share/icons/...
fi
'2>/dev/null' is unnecessary when using 'command': POSIX says "no output
shall be written" if the command isn't found. It's also unnecessary for
the debianutils version of 'which', and hides the deprecation warning.
-- Michael
signature.asc
Description: PGP signature

