* bryan@ak.net <bryan@ak.net> [2004-03-22 00:22 -0900]:
> On Sun, Mar 21, 2004 at 10:40:43PM -0901, David J. Weller-Fahy <dave-lists-aklug@weller-fahy.com> wrote:
> > I've found sticking to the ${VARIABLE} syntax (and including double
> > quotes around it when using it as an argument) when writing scripts
> > saves some headaches.
>
> What's the difference between $VAR and ${VAR}?
Well, according to the man page for sh (long line):
In the 'Variables and Parameters' section, "The shell maintains a set of
parameters. A parameter denoted by a name is called a variable."
Then at the end of the 'Word Expansions' section, "The ``$'' character
is used to introduce parameter expansion, command substitution, or
arithmetic evaluation."
After that, at the beginning of the 'Parameter Expansion' section:
"The parameter name or symbol can be enclosed in braces, which are
optional except for positional parameters with more than one digit or
when parameter is followed by a character that could be interpreted as
part of the name. If a parameter expansion occurs inside double-quotes:
1. Pathname expansion is not performed on the results of the
expansion.
2. Field splitting is not performed on the results of the expansion,
with the exception of the special parameter @."
After all that, here's how I understand it: If you leave out the braces
nothing untoward is *supposed* to happen. However, I've had some bad
luck with weird file names (and within file names) when not using the
braces. That's my reasoning behind it, anyway. ;]
Regards,
-- dave [ please don't CC me ] --------- To unsubscribe, send email to <aklug-request@aklug.org> with 'unsubscribe' in the message body.Received on Mon Mar 22 10:26:23 2004
This archive was generated by hypermail 2.1.8 : Mon Mar 22 2004 - 10:26:23 AKST