Reputation: 23561
I'm trying to locate the real path of the running script , but when $0
was in some folders that contains space , readlink
would fail , so i surrounded $0 with "
, but readlink ceased to work this time.
RPATH="$(readlink -f \"$0\")"
echo $RPATH
Thanks , and if bash itself can do this , it's much more better !
Upvotes: 3
Views: 613
Reputation: 26521
Don't escape the inner quotes. As it is, they are handled to readlink as part of the filename (instead of preventing word splitting).
Upvotes: 3