Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7902192f authored by Felix Ableitner's avatar Felix Ableitner
Browse files

Trim whitespace from input (fixes #1)

parent 7315cf45
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -33,6 +33,11 @@ function getQuestion {
    echo "$INPUT" | sed 's/||||.*$//g'
}

function readInput {
    read INPUT < /dev/tty
    echo $INPUT | awk '{$1=$1};1'
}

function generateEnvFile {
    QUESTFILE="$1"
    ANSWERFILE="$2"
@@ -53,7 +58,7 @@ function generateEnvFile {
                    echo "$QUESTION"
                    if [[ "$PATTERN$INPUT_DIRECTION" = "$VALUE$VALUE" ]]
                    then
                        read INPUT < /dev/tty
                        INPUT=$(readInput)
                    else
                        FIRST=1
                        while [[ $(echo "$INPUT" | grep -q -P "$PATTERN" && echo ok || echo nok) = "nok" ]]; do
@@ -63,7 +68,7 @@ function generateEnvFile {
                            else
                                FIRST=0
                            fi
                            read INPUT < /dev/tty
                            INPUT=$(readInput)
                         :; done
                    fi
                    echo "$KEY=$INPUT" >> "$ENVFILE"