Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
How about this for bash: #!/bin/bash echo "What is your web application root?" read web_application_root web_application_root="$(envsubst <<< "$web_application_root")" echo web_...
Answer
#2: Post edited
- How about this for bash:
- ```
- #!/bin/bash
- echo "What is your web application root?"
IFS= read web_application_root- web_application_root="$(envsubst <<< "$web_application_root")"
- echo web_application_root=$web_application_root
- ```
`IFS=` helps you deal with spaces. `envsubst` does the environment variable expansion for you. For example:- ```
- $ ./test.sh
- What is your web application root?
- ${HOME}/a b
- web_application_root=/home/Someone/a b
- ```
- How about this for bash:
- ```
- #!/bin/bash
- echo "What is your web application root?"
- read web_application_root
- web_application_root="$(envsubst <<< "$web_application_root")"
- echo web_application_root=$web_application_root
- ```
- `envsubst` does the environment variable expansion for you. For example:
- ```
- $ ./test.sh
- What is your web application root?
- ${HOME}/a b
- web_application_root=/home/Someone/a b
- ```
#1: Initial revision
How about this for bash: ``` #!/bin/bash echo "What is your web application root?" IFS= read web_application_root web_application_root="$(envsubst <<< "$web_application_root")" echo web_application_root=$web_application_root ``` `IFS=` helps you deal with spaces. `envsubst` does the environment variable expansion for you. For example: ``` $ ./test.sh What is your web application root? ${HOME}/a b web_application_root=/home/Someone/a b ```