From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id EEF693858D33; Fri, 8 Mar 2024 14:27:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEF693858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709908054; bh=vz9OBkgpP1MPe5l98RC7Y35ZVnLqw0ebWzYYGiWDllI=; h=From:To:Subject:Date:From; b=e5yFDdgH7uUkcxqAVVigkUbZ+uEU+qwSbDQ2mtoq1oupEJ0gVdPM9tmt1Te3Sok2s Teu5uSBxsjjLjSHtOmhrQF/1GTR0jbzTYLxVUbPUOHRf1/h0UdtBLzVa/kpg8mcNRW H3xHeLATGIw3tHhV/T8GJMZimRD5NS72hVzM3hpY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9393] contrib: Improve dg-extract-results.sh's Python detection [PR109668] X-Act-Checkin: gcc X-Git-Author: Sam James X-Git-Refname: refs/heads/master X-Git-Oldrev: 8263a4b6505f84973c2ed2fb8d4f2036ca335ff3 X-Git-Newrev: 64273a7e6bd8ba60058174d147521dd65d705637 Message-Id: <20240308142734.EEF693858D33@sourceware.org> Date: Fri, 8 Mar 2024 14:27:34 +0000 (GMT) List-Id: https://gcc.gnu.org/g:64273a7e6bd8ba60058174d147521dd65d705637 commit r14-9393-g64273a7e6bd8ba60058174d147521dd65d705637 Author: Sam James Date: Fri Mar 8 15:24:20 2024 +0100 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. Diff: --- contrib/dg-extract-results.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/contrib/dg-extract-results.sh b/contrib/dg-extract-results.sh index 00ef80046f7..539d596a89d 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 <&2