Skip to content

Commit c972637

Browse files
committed
migrate.sh: clean up user argument parsing
1 parent b10828f commit c972637

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

module/migrate.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
#!/bin/sh
22

3-
case "$1" in
4-
-h|--help|help) echo "sh migrate.sh [-f] [-o] [-a] [in-file] [out-file]"; exit 0;;
5-
esac;
6-
73
N="
84
";
95

106
case "$1" in
7+
-h|--help|help) echo "sh migrate.sh [-f] [-o] [-a] [in-file] [out-file]"; exit 0;;
118
-i|--install|install) INSTALL=1; shift;;
129
*) echo "custom.pif.json migration script \
1310
$N by osm0sis @ xda-developers $N";;
@@ -27,15 +24,14 @@ grep_check_json() {
2724
grep -q "$1" "$target" && [ "$(grep_get_json $1 "$target")" ];
2825
}
2926

30-
case "$1" in
31-
-f|--force|force) FORCE=1; shift;;
32-
esac;
33-
case "$1" in
34-
-o|--override|override) OVERRIDE=1; shift;;
35-
esac;
36-
case "$1" in
37-
-a|--advanced|advanced) ADVANCED=1; shift;;
38-
esac;
27+
until [ -z "$1" -o -f "$1" ]; do
28+
case "$1" in
29+
-f|--force|force) FORCE=1; shift;;
30+
-o|--override|override) OVERRIDE=1; shift;;
31+
-a|--advanced|advanced) ADVANCED=1; shift;;
32+
*) die "Invalid argument/file not found: $1";;
33+
esac;
34+
done;
3935

4036
if [ -f "$1" ]; then
4137
FILE="$1";

0 commit comments

Comments
 (0)