From 8730da8aeb5abb42e7f29ed767680d9f5258fb06 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 1 Jul 2022 11:51:35 +0200 Subject: setup-ntp: fix non-interactive -c option We should not prompt user when -c is specified, in which case $1 is empty. fixes https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10522 --- setup-ntp.in | 2 +- tests/setup_ntp_test | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/setup-ntp.in b/setup-ntp.in index af35e05..9f48d72 100644 --- a/setup-ntp.in +++ b/setup-ntp.in @@ -27,7 +27,7 @@ while getopts "hc:" opt; do done shift $(( $OPTIND - 1 )) -resp=$1 +: ${resp:=$1} while [ $# -eq 0 ] && ! isin "$resp" busybox openntpd chrony none abort; do ask "Which NTP client to run? ('busybox', 'openntpd', 'chrony' or 'none')" chrony diff --git a/tests/setup_ntp_test b/tests/setup_ntp_test index 8294232..6746277 100755 --- a/tests/setup_ntp_test +++ b/tests/setup_ntp_test @@ -6,7 +6,9 @@ init_tests \ setup_ntp_invalid \ setup_ntp_busybox \ setup_ntp_chrony \ - setup_ntp_openntpd + setup_ntp_openntpd \ + setup_ntp_none \ + setup_ntp_none_backwards_compat setup_ntp_usage_body() { test_usage setup-ntp @@ -43,3 +45,16 @@ setup_ntp_openntpd_body() { -o match:"Starting openntpd" \ setup-ntp openntpd } + +setup_ntp_none_body() { + init_env + atf_check -s exit:0 \ + setup-ntp none +} + +setup_ntp_none_backwards_compat_body() { + init_env + atf_check -s exit:0 \ + setup-ntp -c none +} + -- cgit v1.2.3