simplify getopts loops in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
36b7f01a8a
commit
67f4919ffe
|
@ -38,26 +38,14 @@ main()
|
|||
while getopts b:m:u:c:x: option
|
||||
do
|
||||
case "${1}" in
|
||||
-b)
|
||||
mode="all"
|
||||
shift ;;
|
||||
-u)
|
||||
mode="oldconfig"
|
||||
shift ;;
|
||||
-m)
|
||||
mode="menuconfig"
|
||||
shift ;;
|
||||
-c)
|
||||
mode="distclean"
|
||||
shift ;;
|
||||
-x)
|
||||
mode="crossgcc-clean"
|
||||
shift ;;
|
||||
*)
|
||||
fail "Invalid option" ;;
|
||||
-b) mode="all" ;;
|
||||
-u) mode="oldconfig" ;;
|
||||
-m) mode="menuconfig" ;;
|
||||
-c) mode="distclean" ;;
|
||||
-x) mode="crossgcc-clean" ;;
|
||||
*) fail "Invalid option" ;;
|
||||
esac
|
||||
project="${OPTARG}"
|
||||
shift
|
||||
shift; project="${OPTARG}"; shift
|
||||
done
|
||||
[ -z "${mode}" ] && fail "mode not given (-m, -u or -b)"
|
||||
|
||||
|
|
|
@ -15,16 +15,11 @@ main()
|
|||
while getopts b:c: option
|
||||
do
|
||||
case "${1}" in
|
||||
-b)
|
||||
shift ;;
|
||||
-c)
|
||||
mode="distclean"
|
||||
shift ;;
|
||||
*)
|
||||
err "Invalid option" ;;
|
||||
-b) : ;;
|
||||
-c) mode="distclean" ;;
|
||||
*) err "Invalid option" ;;
|
||||
esac
|
||||
project="${OPTARG}"
|
||||
shift
|
||||
shift; project="${OPTARG}"; shift
|
||||
done
|
||||
|
||||
[ -z "${project}" ] && err "project name not specified"
|
||||
|
|
|
@ -23,12 +23,9 @@ main()
|
|||
while getopts r:b:m: option
|
||||
do
|
||||
case "${option}" in
|
||||
r)
|
||||
rom=${OPTARG} ;;
|
||||
b)
|
||||
board=${OPTARG} ;;
|
||||
m)
|
||||
modifygbe=true
|
||||
r) rom=${OPTARG} ;;
|
||||
b) board=${OPTARG} ;;
|
||||
m) modifygbe=true
|
||||
new_mac=${OPTARG} ;;
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue