daisy
daisy

Reputation: 23561

readlink not working when parameters is surrounded with double quote

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

Answers (1)

Jo So
Jo So

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

Related Questions