[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using the variable name, GROUPS, in a read list
From: |
Bob Proulx |
Subject: |
Re: using the variable name, GROUPS, in a read list |
Date: |
Wed, 7 Mar 2012 11:38:03 -0700 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Greg Wooledge wrote:
> Jim Meyering wrote:
> > Is there a moral here, other than to avoid using special variable names?
> > Probably to prefer lower-case variable names.
>
> You've nailed it. Or more precisely, avoid all-upper-case variable names,
> because they tend to collide with environment variables and special shell
> variables. Any variable name with at least one lower-case letter should
> be safe.
>
> There is an unfortunate long-lived bad habit that's floating around out
> there, where people think they're supposed to use all-caps variable names
> in shell scripts. That is not a good idea, and you've just stumbled upon
> one of the many reasons why.
I always used to use upper case shell variable names too. (For
example TMPDIR, but that collides with other behavior.) But due to
the collision potential I have been trying to train myself out of that
habit for the last few years. Now I always use lower case variable
names. (For example tmpdir, which shouldn't collide.)
So for this I would say the script should use lower case names instead
of upper case names.
Bob
- using the variable name, GROUPS, in a read list, Jim Meyering, 2012/03/07
- Re: using the variable name, GROUPS, in a read list, Greg Wooledge, 2012/03/07
- Re: using the variable name, GROUPS, in a read list,
Bob Proulx <=
- Re: using the variable name, GROUPS, in a read list, Roman Rakus, 2012/03/07