Skip to content

Commit

Permalink
Replace which with command -v
Browse files Browse the repository at this point in the history
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/.
  • Loading branch information
paulo-erichsen authored and anishathalye committed Nov 9, 2019
1 parent 5bb3c8a commit d2913e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bin/dotbot
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion test/tests/find-python-executable.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
'

Expand Down

0 comments on commit d2913e6

Please sign in to comment.