migrate.sh: clean up user argument parsing

This commit is contained in:
Chris Renshaw
2024-09-22 18:34:16 -03:00
committed by osm0sis
parent b10828f199
commit c972637347

View File

@@ -1,13 +1,10 @@
#!/bin/sh #!/bin/sh
case "$1" in
-h|--help|help) echo "sh migrate.sh [-f] [-o] [-a] [in-file] [out-file]"; exit 0;;
esac;
N=" N="
"; ";
case "$1" in case "$1" in
-h|--help|help) echo "sh migrate.sh [-f] [-o] [-a] [in-file] [out-file]"; exit 0;;
-i|--install|install) INSTALL=1; shift;; -i|--install|install) INSTALL=1; shift;;
*) echo "custom.pif.json migration script \ *) echo "custom.pif.json migration script \
$N by osm0sis @ xda-developers $N";; $N by osm0sis @ xda-developers $N";;
@@ -27,15 +24,14 @@ grep_check_json() {
grep -q "$1" "$target" && [ "$(grep_get_json $1 "$target")" ]; grep -q "$1" "$target" && [ "$(grep_get_json $1 "$target")" ];
} }
case "$1" in until [ -z "$1" -o -f "$1" ]; do
-f|--force|force) FORCE=1; shift;; case "$1" in
esac; -f|--force|force) FORCE=1; shift;;
case "$1" in -o|--override|override) OVERRIDE=1; shift;;
-o|--override|override) OVERRIDE=1; shift;; -a|--advanced|advanced) ADVANCED=1; shift;;
esac; *) die "Invalid argument/file not found: $1";;
case "$1" in esac;
-a|--advanced|advanced) ADVANCED=1; shift;; done;
esac;
if [ -f "$1" ]; then if [ -f "$1" ]; then
FILE="$1"; FILE="$1";