Skip to content

Commit

Permalink
build: fix inability to detect correct python command in configure
Browse files Browse the repository at this point in the history
The "which" utility is not guaranteed to be installed, and if it is, its
behavior is not portable.

Conversely, the "command -v" shell builtin is required to exist in all
POSIX 2008 compliant shells, and is thus guaranteed to work everywhere.

Examples of open-source shells likely to be installed as /bin/sh on
Linux, which implement the 12-year-old standard: ash, bash, busybox,
dash, ksh, mksh and zsh.

Signed-off-by: Eli Schwartz <[email protected]>

PR-URL: #32925
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Matheus Marchini <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
eli-schwartz authored and codebytere committed Jun 18, 2020
1 parent 8b887c4 commit 8ed25ed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# as is the fact that the ] goes on a new line.
_=[ 'exec' '/bin/sh' '-c' '''
test ${FORCE_PYTHON2} && exec python2 "$0" "$@" # workaround for gclient
which python3.8 >/dev/null && exec python3.8 "$0" "$@"
which python3.7 >/dev/null && exec python3.7 "$0" "$@"
which python3.6 >/dev/null && exec python3.6 "$0" "$@"
which python3.5 >/dev/null && exec python3.5 "$0" "$@"
which python2.7 >/dev/null && exec python2.7 "$0" "$@"
command -v python3.8 >/dev/null && exec python3.8 "$0" "$@"
command -v python3.7 >/dev/null && exec python3.7 "$0" "$@"
command -v python3.6 >/dev/null && exec python3.6 "$0" "$@"
command -v python3.5 >/dev/null && exec python3.5 "$0" "$@"
command -v python2.7 >/dev/null && exec python2.7 "$0" "$@"
exec python "$0" "$@"
''' "$0" "$@"
]
Expand Down

0 comments on commit 8ed25ed

Please sign in to comment.