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]}\")"
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]}\")"
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]}")"