[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Franklin, Jason
Subject: Re: GROUPS
Date: Mon, 09 Aug 2021 22:00:25 -0400
User-agent: Evolution 3.36.5-0ubuntu1

Hey, Greg!

I presume that you are the Wooledge who hosts the BashFAQ.

If so, thanks for hosting that.  It's a huge help.  :)

On Mon, 2021-08-09 at 20:36 -0400, Greg Wooledge wrote:
> On Mon, Aug 09, 2021 at 05:35:56PM -0400, Franklin, Jason wrote:
> > Should bash, invoked with "--posix" or as "sh", omit the special
> > treatment of variables such as GROUPS?
> I would say no.  Using all-caps variable names is a bad idea for
> precisely this reason -- you never know when it'll be something
> special, in your shell or in your operating system.

I agree.  All-caps is the exception for variables... not the rule.

I did not write the scripts in question.  These were actually Debian
package maintainer scripts that started failing.

Perhaps I'll get a test added to "checkbashisms" that looks for this.

> Always use at least one lower-case letter in each variable name, unless
> you're actually exporting something as an environment variable, and
> you know that the name is not used by anything else in your working
> environment.

The problem was avoidable with good style.  That we can agree on.

I do think the current configuration goes against the Principle of Least
Astonishment.  However, shell scripting is always astonishing, so I'm
ultimately not astonished.

If I run a script against a POSIX-compliant (PC) shell using only PC
syntax/features and then I run the same script with Bash in PC mode, I
would expect an identical result.  To me, anything else indicates a bug
in one of the shells.  Perhaps this assessment is naive.

Fixing this may be more trouble than it's worth.  Also, there are
probably many scripts out there that rely on what I perceive to be the
incorrect behavior.  Such is life.

Anyway... thanks for listening!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]