From 2781ddf6a3a06339521c5ab67e7cd7ae53dc1f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fr=C3=A9rot?= Date: Tue, 31 Dec 2024 13:34:53 +0100 Subject: [PATCH] added conditional prompt function --- rtenets | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rtenets b/rtenets index c74ba02..2d79996 100755 --- a/rtenets +++ b/rtenets @@ -77,10 +77,23 @@ alt_var() { if is_set "${variable}"; then printf "%s" "$(eval "printf \"%s\" \"\${${variable}}\"")" else - printf "%s" "$value_if_unset" + printf "%s" "${value_if_unset}" fi } +# Enter value if unset +cond_enter() { + local input="$1" + local var_name="$2" + local value="$(alt_var "" "${var_name}")" + + if [[ "${value}" == "" ]]; then + value="$(enter "${input}")" + fi + + printf "%s" "${value}" +} + # Check that command exists has_command() { command -v "$1" >/dev/null 2>&1