-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC1135
Vidar Holen edited this page Jul 1, 2019
·
1 revision
echo "The apples are $""1 each"
eval "var=$"name
echo "The apples are \$1 each"
eval "var=\$name"
# or better yet: var="${!name}"
The script appears to be closing a double quoted string for the sole purpose of making a dollar sign $
literal.
While this happens to work, the better solution is instead to escape it with a backslash. This allows the double quoted string to continue uninterrupted, thereby reducing the visual noise of stopping and starting quotes in the middle of a shell word.
None
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!