This commit is contained in:
Daniel Langbein 2021-05-01 13:41:31 +02:00
parent c41ef5c9ce
commit ef2f96617b
4 changed files with 12 additions and 12 deletions

View File

@ -16,7 +16,7 @@ function get_text_input {
fi fi
done done
local -n ptr=$1 local -n ptr=$1 || return $?
if [ -z "$ptr" ]; then if [ -z "$ptr" ]; then
# if ptr has no value yet, ask user for input! # if ptr has no value yet, ask user for input!
echo "$2" echo "$2"
@ -48,11 +48,11 @@ function get_single_choice {
done done
local -n ptr=$1 local -n ptr=$1 || return $?
if [ -z "$ptr" ]; then if [ -z "$ptr" ]; then
# if ptr has no value yet, ask user for input! # if ptr has no value yet, ask user for input!
local -n MENU_OPTIONS=$3 local -n MENU_OPTIONS=$3 || return $?
ptr=$(dialog --stdout --menu "$2" 0 0 0 "${MENU_OPTIONS[@]}") || { ptr=$(dialog --stdout --menu "$2" 0 0 0 "${MENU_OPTIONS[@]}") || {
echo "Error during menu selection!" echo "Error during menu selection!"
exit 1 exit 1
@ -79,11 +79,11 @@ function get_multi_choice {
done done
local -n ptr=$1 local -n ptr=$1 || return $?
if [ -z "$ptr" ]; then if [ -z "$ptr" ]; then
# if ptr has no value yet, ask user for input! # if ptr has no value yet, ask user for input!
local -n MENU_OPTIONS=$3 local -n MENU_OPTIONS=$3 || return $?
TMP1=$(dialog --stdout --checklist "$2" 0 0 0 "${MENU_OPTIONS[@]}") || { TMP1=$(dialog --stdout --checklist "$2" 0 0 0 "${MENU_OPTIONS[@]}") || {
echo "Error during menu selection!" echo "Error during menu selection!"
exit 1 exit 1

View File

@ -2,7 +2,7 @@ function newline_to_space() {
# Replaces all newlines with spaces # Replaces all newlines with spaces
# $1: name of variable # $1: name of variable
local -n ptr=$1 local -n ptr=$1 || return $?
# Replace newlines with spaces # Replace newlines with spaces
# See bash string substitution: https://gist.github.com/JPvRiel/b279524d3e56229a896477cb8082a72b # See bash string substitution: https://gist.github.com/JPvRiel/b279524d3e56229a896477cb8082a72b
@ -18,8 +18,8 @@ function newline_separated_to_array() {
# $1: name of variable with newline separated list # $1: name of variable with newline separated list
# $2: name of array to store values into # $2: name of array to store values into
local -n ptr=$1 local -n ptr=$1 || return $?
local -n ptr2=$2 local -n ptr2=$2 || return $?
# ptr newline separated list. # ptr newline separated list.
# Store this as array ptr2. # Store this as array ptr2.
readarray -t ptr2 <<<"$ptr" readarray -t ptr2 <<<"$ptr"
@ -29,8 +29,8 @@ function space_separated_to_array() {
# $1: name of variable with space separated list # $1: name of variable with space separated list
# $2: name of array to store values into # $2: name of array to store values into
local -n ptr=$1 local -n ptr=$1 || return $?
local -n ptr2=$2 local -n ptr2=$2 || return $?
# ptr space separated list. # ptr space separated list.
# Store this as array ptr2. # Store this as array ptr2.
# Without newline at last array element: https://unix.stackexchange.com/a/519917/315162 # Without newline at last array element: https://unix.stackexchange.com/a/519917/315162

View File

@ -18,7 +18,7 @@ function text_input {
return 1 return 1
fi fi
local -n ptr=$1 local -n ptr=$1 || return $?
if [ -z "$ptr" ]; then if [ -z "$ptr" ]; then
echo "$2" echo "$2"
read -r ptr || return $? read -r ptr || return $?