added conditional prompt function
This commit is contained in:
parent
2e6f71842f
commit
2781ddf6a3
15
rtenets
15
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
|
||||
|
|
Loading…
Reference in New Issue