]> git.ozlabs.org Git - next-scripts/commitdiff
message_helper: use getopts
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 21 Aug 2025 02:00:42 +0000 (12:00 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 21 Aug 2025 02:00:42 +0000 (12:00 +1000)
message_helper

index 35b60095a362aac993e689604c75a15b5c84a5bc..32ee641819b982af15345304ac90b89748bd39d5 100755 (executable)
@@ -9,16 +9,16 @@ if [ -f merge.log ]; then
 fi
 
 branch=
-if [ "$1" = '-b' ]; then
-        branch="$2"
-        shift 2
-fi
-
 kconfig=
-if [ "$1" = '-c' ]; then
-        kconfig="$2"
-        shift 2
-fi
+
+while getopts 'b:c:' opt; do
+       case "$opt" in
+       b) branch="$OPTARG" ;;
+       c) kconfig="$OPTARG" ;;
+       *) printf '%s: bad option' "$0"; exit 1 ;;
+       esac
+done
+shift $(( OPTIND - 1 ))
 
 subject="$1"
 shift