diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index cdc71f0..7c3bed9 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -115,7 +115,7 @@ function get_multi_choice { # if ptr has no value yet, ask user for input! local -n MENU_OPTIONS=$3 - local tmp=$(dialog --stdout --checklist "$2" 0 0 0 ${MENU_OPTIONS}) || { + TMP1=$(dialog --stdout --checklist "$2" 0 0 0 ${MENU_OPTIONS}) || { echo "Error during menu selection!" exit 1 } @@ -123,7 +123,10 @@ function get_multi_choice { # Result of dialog is space separated list # Store this as an array - readarray -d " " -t ptr <<<"$tmp" + # Without newline at last array element: https://unix.stackexchange.com/a/519917/315162 + # readarray -d " " -t ptr < <(printf '%s' "$TMP1") + # + space_separated_to_array TMP1 "$1" fi } @@ -246,21 +249,17 @@ function choose_mount_options() { esac get_multi_choice FS_MOUNT_OPTIONS "Select mount options" TMP1 || return $? - - # TODO: test FS_MOUNT_OPTIONS - echo "${FS_MOUNT_OPTIONS[@]}" - echo "${#FS_MOUNT_OPTIONS[@]}" - for i in "${FS_MOUNT_OPTIONS[@]}"; do - echo "<<$i>>" - done } function main() { check_network || return $? get_user_input || return $? get_cpu_vendor || return $? + get_default_mount_options || return $? choose_mount_options || return $? + + # TODO: use FS_DEFAULT_MOUNT_OPTIONS and FS_MOUNT_OPTIONS in combination } main "$@" diff --git a/pkg/de-p1st-installer/helper.sh b/pkg/de-p1st-installer/helper.sh index b2cd383..9ed5ce4 100644 --- a/pkg/de-p1st-installer/helper.sh +++ b/pkg/de-p1st-installer/helper.sh @@ -1,4 +1,4 @@ -function newline_to_space(){ +function newline_to_space() { # Replaces all newlines with spaces # $1: name of variable @@ -6,12 +6,27 @@ function newline_to_space(){ # Replace newlines with spaces # See bash string substitution: https://gist.github.com/JPvRiel/b279524d3e56229a896477cb8082a72b - echo "removing newlines in str: -->$ptr<--" + # echo "removing newlines in str: -->$ptr<--" ptr="${ptr//$'\n'/' '}" - echo "new str is: -->$ptr<--" + # echo "new str is: -->$ptr<--" } -function get_block_devices(){ +function space_separated_to_array() { + # $1: name of variable with space separated list + # $2: name of array to store values into + + local -n ptr=$1 + local -n ptr2=$2 + # ptr space separated list. + # Store this as array ptr2. + # Without newline at last array element: https://unix.stackexchange.com/a/519917/315162 + readarray -d " " -t ptr2 < <(printf '%s' "$ptr") +} + + + + +function get_block_devices() { # return: the following variables: # BLOCK_DEVICES (array with each block device as one entry)