I have a bash function that prompts user to input certain data.I tried it with first name, last name, birthday etc.Data that is mostly represented in one sentence.When I ask for street + no. the function breaks, because itcan't handle spaces.askForData 'Please enter your street and number' STREETI get following error.Please enter your street and number: ExampleStreet 123func_askForData: line 21: 123: command not foundHow can I extend my function to accept sentences?file: func_askForData#!/bin/bash# Usage askForData Prompt for value VARIABLE# Prints out prompt and stores input in VARIABLE# # Prompt is printed till non-empty input is made.function askForData(){local PROMPT=${1}eval local VAR_NAME=${2}local CONTINUE=truewhile ${CONTINUE}    do        read -p ${PROMPT}:  VAR_VALUE        if [ -z $VAR_VALUE ]; then            CONTINUE=true        else            CONTINUE=false            eval ${VAR_NAME}=${VAR_VALUE}        fi    done}Additional infobash --versionGNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)Copyright (C) 2007 Free Software Foundation, Inc.
Prompt user for sentence and store it without being disturbed by spaces
bash;shell script;quoting
Useeval ${VAR_NAME}='${VAR_VALUE}'With eval, you get in general a two-fold expansion. If there are any things in an eval statement that should be expanded only once, it's usually better to quote them in such a way that the first expansion does nothing (except for quote removal) and the second expansion does the main job. In this concrete case, the first expansion yieldsSTREET=${VAR_VALUE}which is then executed correctly during the second expansion. If you try to do it the other way round, it's difficult to ensure that the result of the first expansion remains unchanged during the second expansion. I also have the impression that the first eval (before local VAR_NAME=${2} is superfluous.