]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
contrib: Improve dg-extract-results.sh's Python detection [PR109668]
authorSam James <sam@gentoo.org>
Fri, 8 Mar 2024 14:24:20 +0000 (15:24 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 15 Mar 2024 23:28:39 +0000 (00:28 +0100)
'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.

(cherry picked from commit 64273a7e6bd8ba60058174d147521dd65d705637)

contrib/dg-extract-results.sh

index 33968ed7b236bc063c3b87e8ab6c9e977a8b7f2a..3c8a5ca0ecf6d6f9eec084815c8f79311b032dbf 100755 (executable)
 
 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