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/.
pull/156/head
Paulo Fagundes 3 years ago committed by Anish Athalye
parent 5bb3c8a343
commit d2913e6cee
  1. 6
      bin/dotbot
  2. 2
      test/tests/find-python-executable.bash

@ -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
'''

@ -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
'

Loading…
Cancel
Save