Reputation: 962
Given this bash statement:
config_file=""$(dirname "$0")"/config.sh"
Is the expression interpreted as:
"" + $(dirname "$0") + "/config.sh"
or as:
"$(dirname "$0")"/config.sh
What should be the "proper" way of writing the expression/statement?
Upvotes: 1
Views: 29
Reputation: 361645
It's the first one. You can jump in and out of quotes within the same word and all the adjacent pieces are concatenated.
The leading ""
is removed, and the trailing "/config.sh"
is equivalent to an unquoted /config.sh
since it contains no special characters. The whole thing is therefore the same as:
config_file=$(dirname "$0")/config.sh
Upvotes: 2