Nested quotes in KSH $( ... ) expression
- From: Norman Bullen <norm@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 20 Mar 2009 21:06:46 -0700
I copied this snippet of Korn Shell script from a message on this group
some time ago. It is supposed to return the path to the directory in
which the executing script is installed.
[ -e "$cmd" ] || cmd=$(command -v -- "$cmd") || exit
cd -P -- "$(dirname -- "$cmd")" >/dev/null && pwd -P
Now that I need to use it, I'm noticing the nested levels of double
quotes (") with the inner pair inside the $( ... ) expression. I don't
see anything that specifically allows this in my Bolsky and Korn book.
Will it work?
If this won't work, is there any other way to get the path to the directory containing $0, assuming that $0 or the path to it may contain spaces?
To reply, change domain to an adult feline.