]> git.ozlabs.org Git - next-scripts/commitdiff
do_merge: switch to using getopts
authorStephen Rothwell <sfr@canb.auug.org.au>
Fri, 26 Jul 2019 00:40:07 +0000 (10:40 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 26 Jul 2019 00:40:07 +0000 (10:40 +1000)
do_merge

index 01d7f1c01bbdc1220680286639b0419a2780d264..1c91fe5618a6fe01bdd872230b424bb0c5f0194e 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -3,19 +3,20 @@
 no_build=false
 start_from=""
 
-[ "$1" = "-n" ] && {
-       shift
-       no_build=true
-}
-[ "$1" = "-s" ] && {
-       shift
-       start_from="$1"
-       [ -z "$start_from" ] && {
-               echo "-s requires a start tree" 1>&2
+while getopts 'ns:' opt; do
+       case "$opt" in
+       n)
+               no_build=true
+               ;;
+       s)
+               start_from="$OPTARG"
+               ;;
+       *)
                exit 1
-       }
-       shift
-}
+               ;;
+       esac
+done
+shift $((OPTIND - 1))
 
 tool_dir=$(dirname "$0")
 . "$tool_dir/common.sh"