Mun wrote:
I am moving from ksh93 to bash and have a question regarding the usage
of ${parameter:-word} parameter expansion.
In ksh, I use ${*:-.} as an argument to commands. For example:
function ll
{
ls --color -Flv ${*:-.}
}
This technique passes '.' as an arg to 'ls' if I didn't pass any args on
the command line (as I'm sure you all already know). But this does not
work with bash; nor have I been able to come up with a technique that
accomplishes the same thing. My only workaround so far is to put an
'if' loop around the 'ls' that tests $# and takes the appropriate branch
depending on the number of args (i.e., 0 or non-zero).
Any suggestions would be welcomed. Thanks in advance.
Not sure why the above doesn't work, though you probably mean to use
"$@" and not $* (presence/absence of ""s is intentional). This seems to
work for me:
function ll
{
ls --color -Flv "${@:-.}"
}
--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
"It's not easy for [Microsoft] to accept [competing fairly]"
-- Dave Heiner (a Microsoft VP, paraphrased)