diff options
author | Sam James <sam@gentoo.org> | 2024-03-08 15:24:20 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-03-08 15:24:20 +0100 |
commit | 64273a7e6bd8ba60058174d147521dd65d705637 (patch) | |
tree | d543d22fe31d8b63183ee8291c3a069bf70f4755 /contrib | |
parent | 8263a4b6505f84973c2ed2fb8d4f2036ca335ff3 (diff) | |
download | gcc-64273a7e6bd8ba60058174d147521dd65d705637.zip gcc-64273a7e6bd8ba60058174d147521dd65d705637.tar.gz gcc-64273a7e6bd8ba60058174d147521dd65d705637.tar.bz2 |
contrib: Improve dg-extract-results.sh's Python detection [PR109668]
'python' on some systems (e.g. SLES 15) might be Python 2. Prefer python3,
then python, then python2 (as the script still tries to work there).
PR other/109668
* dg-extract-results.sh: Check for python3 before python. Check for
python2 last.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/dg-extract-results.sh | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/contrib/dg-extract-results.sh b/contrib/dg-extract-results.sh index 00ef800..539d596 100755 --- a/contrib/dg-extract-results.sh +++ b/contrib/dg-extract-results.sh @@ -28,14 +28,17 @@ PROGNAME=dg-extract-results.sh -# Try to use the python version if possible, since it tends to be faster. +# Try to use the python version if possible, since it tends to be faster and +# produces more stable results. PYTHON_VER=`echo "$0" | sed 's/sh$/py/'` -if test "$PYTHON_VER" != "$0" && - test -f "$PYTHON_VER" && - python -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \ - > /dev/null 2> /dev/null; then - exec python $PYTHON_VER "$@" -fi +for python in python3 python python2 ; do + if test "$PYTHON_VER" != "$0" && + test -f "$PYTHON_VER" && + ${python} -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \ + > /dev/null 2> /dev/null; then + exec ${python} $PYTHON_VER "$@" + fi +done usage() { cat <<EOF >&2 |