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
|
while getopts b:m:u:c:x: option
|
||||||
do
|
do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-b)
|
-b) mode="all" ;;
|
||||||
mode="all"
|
-u) mode="oldconfig" ;;
|
||||||
shift ;;
|
-m) mode="menuconfig" ;;
|
||||||
-u)
|
-c) mode="distclean" ;;
|
||||||
mode="oldconfig"
|
-x) mode="crossgcc-clean" ;;
|
||||||
shift ;;
|
*) fail "Invalid option" ;;
|
||||||
-m)
|
|
||||||
mode="menuconfig"
|
|
||||||
shift ;;
|
|
||||||
-c)
|
|
||||||
mode="distclean"
|
|
||||||
shift ;;
|
|
||||||
-x)
|
|
||||||
mode="crossgcc-clean"
|
|
||||||
shift ;;
|
|
||||||
*)
|
|
||||||
fail "Invalid option" ;;
|
|
||||||
esac
|
esac
|
||||||
project="${OPTARG}"
|
shift; project="${OPTARG}"; shift
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
[ -z "${mode}" ] && fail "mode not given (-m, -u or -b)"
|
[ -z "${mode}" ] && fail "mode not given (-m, -u or -b)"
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,11 @@ main()
|
||||||
while getopts b:c: option
|
while getopts b:c: option
|
||||||
do
|
do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-b)
|
-b) : ;;
|
||||||
shift ;;
|
-c) mode="distclean" ;;
|
||||||
-c)
|
*) err "Invalid option" ;;
|
||||||
mode="distclean"
|
|
||||||
shift ;;
|
|
||||||
*)
|
|
||||||
err "Invalid option" ;;
|
|
||||||
esac
|
esac
|
||||||
project="${OPTARG}"
|
shift; project="${OPTARG}"; shift
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z "${project}" ] && err "project name not specified"
|
[ -z "${project}" ] && err "project name not specified"
|
||||||
|
|
|
@ -23,12 +23,9 @@ main()
|
||||||
while getopts r:b:m: option
|
while getopts r:b:m: option
|
||||||
do
|
do
|
||||||
case "${option}" in
|
case "${option}" in
|
||||||
r)
|
r) rom=${OPTARG} ;;
|
||||||
rom=${OPTARG} ;;
|
b) board=${OPTARG} ;;
|
||||||
b)
|
m) modifygbe=true
|
||||||
board=${OPTARG} ;;
|
|
||||||
m)
|
|
||||||
modifygbe=true
|
|
||||||
new_mac=${OPTARG} ;;
|
new_mac=${OPTARG} ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue