[1/3] contrib/regression/btest-gcc.sh: Handle multiple options.

Message ID 20231123170736.40CD020427@pchp3.se.axis.com
State Accepted
Headers
Series A few contrib/regression/btest-gcc.sh updates. |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Hans-Peter Nilsson Nov. 23, 2023, 5:07 p.m. UTC
  Deliberately not using getopt.  Tested by adding a line right after this
code echoing $dashj, $add_passes_despite_regression, and $1 (then exit)
and checking that I got it right for combinations of -j j4
--add-passes-despite-regression.

-- >8 --
This is a long-standing bug: passing "-j --add-passes-despite-regression"
or "--add-passes-despite-regression -j" caused the second option to be
treated as TARGET; the first non-option parameter.

	* btest-gcc.sh (Option handling): Handle multiple options.
---
 contrib/regression/btest-gcc.sh | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
  

Patch

diff --git a/contrib/regression/btest-gcc.sh b/contrib/regression/btest-gcc.sh
index 1808fcc392fa..22e8f0398662 100755
--- a/contrib/regression/btest-gcc.sh
+++ b/contrib/regression/btest-gcc.sh
@@ -29,13 +29,16 @@  dashj=''
 # -j<n>:
 #  Pass '-j<n>' to make.
 
-case "$1" in
- --add-passes-despite-regression)
-  add_passes_despite_regression=1; shift;;
- -j*)
-  dashj=$1; shift;;
- -*) echo "Invalid option: $1"; exit 2;;
-esac
+while : ; do
+  case "$1" in
+   --add-passes-despite-regression)
+    add_passes_despite_regression=1; shift;;
+   -j*)
+    dashj=$1; shift;;
+   -*) echo "Invalid option: $1"; exit 2;;
+   *) break;;
+  esac
+done
 
 # TARGET is the target triplet.  It should be the same one as used in
 # constructing PREFIX.  Or it can be the keyword 'native', indicating