Reputation: 40454
I can get the following to work:
self=$(readlink -f "${BASH_SOURCE[0]}")
echo "Sourcing $self"
But not the following (I want a one liner):
echo "Sourcing $(readlink -f \"${BASH_SOURCE[0]}\")"
Upvotes: 0
Views: 45
Reputation: 69198
You could also use
echo 'Sourcing' $(readlink -f "${BASH_SOURCE[0]}")
Upvotes: 0
Reputation: 531055
Command substitution starts a new quoting context, so the quotes in the readlink
command are not nested in the quotes surrounding the argument to echo
. You don't need to escape them.
echo "Sourcing $(readlink -f "${BASH_SOURCE[0]}")"
Upvotes: 1