Bug#992383: debianutils: which is noisy and doesn't suggest a different option
On Wed, Aug 18, 2021 at 12:53:53 -0400, Jason Riedy wrote: > I've been using which for decades, including on SunOS and AIX. When I know > it's a script, less `which foobar` is quick and easy. Adding this to ~/.bashrc or similar might help: which () { bash -c 'command -v "$@"' which "$@"; } It won't find binaries shadowed by shell builtins or functions, though I don't imagine this would be a common problem. -- Michael signature.asc Description: PGP signature
Bug#992383: debianutils: which is noisy and doesn't suggest a different option
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
Bug#992383: debianutils: which is noisy and doesn't suggest a different option
I've been using which for decades, including on SunOS and AIX. When I know it's a script, less `which foobar` is quick and easy. None of the alternatives listed do the same thing. Yes, which has issues, but you're breaking what people have used for a very, very long time. From a bash session: DEPRECATION Since type and command -v were mandated by POSIX, this utility is no longer useful for maintainer scripts and thus will be removed from debianutils. Debian 9 Jul 2021 WHICH(1) ejr@signbit:~/kernel/linux$ type ls ls is aliased to `ls --color=auto --hyperlink=auto' ejr@signbit:~/kernel/linux$ command -v ls alias ls='ls --color=auto --hyperlink=auto' ejr@signbit:~/kernel/linux$ which ls /usr/bin/which: this version of 'which' is deprecated and should not be used. /usr/bin/ls ejr@signbit:~/kernel/linux$ whereis ls ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz ejr@signbit:~/kernel/linux$ whence ls bash: whence: command not found ejr@signbit:~/kernel/linux$ command which ls /usr/bin/which: this version of 'which' is deprecated and should not be used. /usr/bin/ls ejr@signbit:~/kernel/linux$ command -v which ls /usr/bin/which alias ls='ls --color=auto --hyperlink=auto'
Bug#992383: debianutils: which is noisy and doesn't suggest a different option
On Wed, Aug 18, 2021 at 01:28:14PM +0900, Norbert Preining wrote: > it seems that /usr/bin/which from debianutils has been deprecated, which > is ok, but being noisy about it on any invocation, **without** providing > an alternative is a no go, since it might break scripts that parse > output including stderr. > > Please use NEWS, or whatever other channels, and above all, **provide > information on a replacement!** Alternatives include * type * command -v * whereis from util-linux * the which builtin in some interactive shells * the whence builtin in some interactive shells * the which() function included in keyboard-configuration.postinst I don't have a comprehensive list.
Bug#992383: debianutils: which is noisy and doesn't suggest a different option
Package: debianutils Version: 5.0.1-1 Severity: important Hi, it seems that /usr/bin/which from debianutils has been deprecated, which is ok, but being noisy about it on any invocation, **without** providing an alternative is a no go, since it might break scripts that parse output including stderr. Please use NEWS, or whatever other channels, and above all, **provide information on a replacement!** Thanks Norbert -- System Information: Debian Release: 11.0 APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.13.11+ (SMP w/8 CPU threads) Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages debianutils depends on: ii libc6 2.31-15 debianutils recommends no packages. debianutils suggests no packages. -- no debconf information