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.
dir=$(
cmd=$0
[ -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?
--
Norm
To reply, change domain to an adult feline.
.
- Follow-Ups:
- Re: Nested quotes in KSH $( ... ) expression
- From: bsh
- Re: Nested quotes in KSH $( ... ) expression
- From: Jon LaBadie
- Re: Nested quotes in KSH $( ... ) expression
- Prev by Date: Re: Quick Sed Command
- Next by Date: Re: file processing loop is too slow
- Previous by thread: Quick Sed Command
- Next by thread: Re: Nested quotes in KSH $( ... ) expression
- Index(es):