Jim Fell
Jim Fell

Reputation: 14264

Embedding Spaces in String Variable for Bash Command Read

How do I embed spaces in my prompt variable for the read command in my bash script?

rebase_prompt="Proceed with rebase? [y/n] "
read -p $rebase_prompt user_response

When this code runs it appears on the terminal as only "Proceed" waiting for my input.

Proceed

How do I get it to take the full string as the prompt?

Upvotes: 0

Views: 51

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799370

By quoting correctly.

read -p "$rebase_prompt" user_response

Upvotes: 4

Related Questions