Hi Guys,
could someone tell me what this ksh construct does
typeset -r PROG_PWD=${0%/*} does
I understand the -r for readonly but I would very much appreciate a definitive account of what this will set $PROG_PWD to.
If I run this at the cmd line it it gets set to /usr/bin but I would like to know .....why?
cheers
sorry - there is an extra 'does' in the post...
ignore the one on the 'typeset' line
cheers
From the ksh man page:
${parameter%word} Remove Smallest Suffix Pattern. The
word is expanded to produce a
pattern. The parameter expansion
then results in parameter, with the
smallest portion of the suffix
matched by the pattern deleted.
Suppose $0 is /usr/bin/ksh, then ${0%/} means that the / is expanded to /ksh - this is the smallest pattern that you can get, and it is deleted. If you had %%/*, it would be the largest match to the pattern, which would mean /usr/bin/ksh (the output would be nothing).