summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2022-11-04 21:58:39 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2022-11-08 14:59:33 +0000
commit5f31c6266e583cffcc1574aa687fdcb0cd5900cf (patch)
treeb7c9f3660464ddf004e9678ecbbd01dafc4c8122
parentdabbed1f4761a34e4b9913414e42a0f178732c2d (diff)
downloadalpine-conf-5f31c6266e583cffcc1574aa687fdcb0cd5900cf.zip
setup-timezone: exit with 1 on invalid timezone
-rw-r--r--setup-timezone.in55
1 files changed, 27 insertions, 28 deletions
diff --git a/setup-timezone.in b/setup-timezone.in
index 8b48272..65cfb1b 100644
--- a/setup-timezone.in
+++ b/setup-timezone.in
@@ -102,33 +102,32 @@ else
default_timezone=UTC
fi
-
-while true; do
- if [ -n "$ZONE" ]; then
- setup_tz "$zroot"/"$ZONE"
- break
- fi
-
- ask "Which timezone are you in? ('?' for list)" "$default_timezone"
- timezone="$resp"
- case "$timezone" in
- "") continue;;
- "?") show_tz_list; continue;;
- esac
-
- while [ -d "$zroot/$timezone" ]; do
- ask "What sub-timezone of '$timezone' are you in? ('?' for list)"
- zone="$resp"
- case "$zone" in
- "?") show_tz_list "$timezone"; continue;;
+if [ -n "$ZONE" ]; then
+ [ -f "$zroot/$ZONE" ] || die "'$ZONE' is not a valid timezone on this system"
+ setup_tz "$zroot"/"$ZONE"
+else
+ while true; do
+ ask "Which timezone are you in? ('?' for list)" "$default_timezone"
+ timezone="$resp"
+ case "$timezone" in
+ "") continue;;
+ "?") show_tz_list; continue;;
esac
- default_timezone="$timezone"
- timezone="$timezone/$zone"
- done
- if [ -f "$zroot/$timezone" ]; then
- setup_tz "$zroot/$timezone"
- break
- fi
- echo "'$timezone' is not a valid timezone on this system"
-done
+ while [ -d "$zroot/$timezone" ]; do
+ ask "What sub-timezone of '$timezone' are you in? ('?' for list)"
+ zone="$resp"
+ case "$zone" in
+ "?") show_tz_list "$timezone"; continue;;
+ esac
+ default_timezone="$timezone"
+ timezone="$timezone/$zone"
+ done
+
+ if [ -f "$zroot/$timezone" ]; then
+ setup_tz "$zroot/$timezone"
+ break
+ fi
+ echo "'$timezone' is not a valid timezone on this system"
+ done
+fi