Re: [Buildroot] [PATCH 0/1] Build issue related to "command -v"
From: Petr Vorel <hidden>
Date: 2021-09-29 17:31:01
Hi all,
...quoted
Meanwhile, 'which' is not standard, and right now, it misbehaves on Debian by filling the screen with warnings.
'which' is a shell script that is trying to emulate a csh builtin. I've NFI why people keep using it :-)
FYI Yes, version from the Debian's debianutils package was a shell script, but other distros had GNU which [2], which is C code.
The equivalent bourne shell command is 'type'.
I also knew 'type' and was suspicious about 'command -v' support across implemented shell, until I asked [3], because checkbashisms.pl [4] complains about 'type' and it's ok with 'command -v'. 'type' is part of POSIX, but as part of the X/Open Systems Interfaces option (XSI) [5] thus it might not be implemented on very small systems. 'command -v' is POSIX but not extension [6] thus it should be everywhere. I tested 'command -v' is supported by commonly used shells (bash, dash, busybox ash, zsh). Although so does 'type' thus I prefer to use 'command -v' instead of 'type' in shell scripts thus I can check them with checkbashisms.pl.
As for 'command -v' no idea what the POSIX committee had for lunch that day :-) It was probably they same day they added 'fc' (from ksh??)
I cannot comment that, but if you read their definition [5] and [6] has slightly different purpose. Kind regards, Petr [1] https://salsa.debian.org/debian/debianutils/-/commit/3a8dd10b4502f7bae8fc6973c13ce23fc9da7efb [2] https://ftp.gnu.org/gnu/which/which-2.21.tar.gz [3] https://unix.stackexchange.com/a/667293 [4] https://salsa.debian.org/debian/devscripts/-/blob/master/scripts/checkbashisms.pl [5] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html [6] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
David
_______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot