From: Ben Bacarisse on
Seebs <usenet-nospam(a)seebs.net> writes:

> On 2010-02-05, Ben Bacarisse <ben.usenet(a)bsb.me.uk> wrote:
>> A couple of other details: Why use {} round your variables? I find
>> $XKLD simpler and more readable than ${_XKLD}. Second, what are all
>> the initial # characters? Are they, too, from you newsreader when you
>> paste output? Anyway, they confuse matters (at least they confuse me)
>> so you might want to look at removing them.
>
> One of my coworkers does this habitually, I think because:
> 1. It is *sometimes* necessary.
> 2. It is easier to do it always than to sanity-check whether to do it
> on each specific occasion.
>
> Having been burned at least once by "why does $FILE_bar not expand to
> foo_bar", I am sympathetic.

I can see the point though I don't do it myself. One reason may be that
I quote as often as I can remember to do so: "$FILE"_bar.

--
Ben.
From: Seebs on
On 2010-02-06, Kaz Kylheku <kkylheku(a)gmail.com> wrote:
> A better habit is to quote variable expansions. Quoting is sometimes
> necessary depending on the /content/ of the variable.

Hmm. That does have some appeal.

> is completely stupid. You've wasted keystrokes on obviously
> superfluous syntax, and it still screws up if the expansion is subject
> to word splitting.

Unless you WANT the word splitting.

>> Having been burned at least once by "why does $FILE_bar not expand to
>> foo_bar", I am sympathetic.

> Quotes will take care of this: "$FILE"_bar.

True.

To go at it from the other angle, though:

There exist circumstances under which quotes are necessary, and there exist
circumstances under which quotes are specifically undesireable. By contrast,
there exist circumstances under which braces are necessary, but I cannot
think of a single circumstance under which braces break anything.

I tend to view always-bracing shell variables as like always-bracing the
bodies of conditionals and loops in C. It's not necessary, but it isn't
totally ridiculous for someone to adopt a policy of always doing it anyway.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!