[ILUG] Parameter expansion in the shell

Rory Browne rbmlist at gmail.com
Thu Jan 17 13:58:48 GMT 2008


> Personally I would agree with "some people" because I think
> having two ways to do the same thing - one of which breaks in
> certain circumstances - sucks. Why not just have one which
> works reliably?

One reason would be backward compatability. If you suddenly removed
support for "$foo" then a lot of legacy scripts that depend on this
would break. I don't really see a problem with having the $foo as well
as ${foo}, for the times when you need the chain brackets.

Another example is $( cmd ), which is syntactly similar to the
backtick version ` cmd `. It is however argued ( by David Korn IIRC )
that the $() syntax is better but backticks had to be kept there for
backwards compatability with the Bourne shell.

Also I guess I could use ls --almost-all --classify . I challenge you
to find someone who doesn't perfer to use ls -AF. It's still good to
have the long-form available for scripts ( I think long form should
always be used in scripts - more readable ), but short form is fine
for interactive.




> The need for ${foo} is more common with Cheetah than with
> shell I think...



More information about the ILUG mailing list