1
0
Fork 0
mirror of synced 2024-06-16 22:11:13 -04:00

Replace which with command -v

Some distributions such as Arch Linux no longer install `which` by
default through the base package (see
https://www.archlinux.org/news/base-group-replaced-by-mandatory-base-package-manual-intervention-required/).

The maintainers have explained why `command -v` is superior:
https://www.reddit.com/r/archlinux/comments/de1er6/arch_linux_news_base_group_replaced_by_mandatory/f2v8uhu/.
This commit is contained in:
Paulo Fagundes 2019-11-09 10:23:21 -07:00 committed by Anish Athalye
parent 5bb3c8a343
commit d2913e6cee
2 changed files with 4 additions and 4 deletions

View file

@ -7,9 +7,9 @@
# is useful because we don't know the name of the python binary.
''':' # begin python string; this line is interpreted by the shell as `:`
which python >/dev/null 2>&1 && exec python "$0" "$@"
which python3 >/dev/null 2>&1 && exec python3 "$0" "$@"
which python2 >/dev/null 2>&1 && exec python2 "$0" "$@"
command -v python >/dev/null 2>&1 && exec python "$0" "$@"
command -v python3 >/dev/null 2>&1 && exec python3 "$0" "$@"
command -v python2 >/dev/null 2>&1 && exec python2 "$0" "$@"
>&2 echo "error: cannot find python"
exit 1
'''

View file

@ -31,7 +31,7 @@ touch ~/tmp_bin/python &&
chmod +x ~/tmp_bin/python &&
cat >> ~/tmp_bin/python <<EOF
#!$HOME/tmp_bin/bash
exec $(which python)
exec $(command -v python)
EOF
'