bug-bash
[Top][All Lists]
Advanced

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

Re: GROUPS


From: Chet Ramey
Subject: Re: GROUPS
Date: Tue, 10 Aug 2021 10:11:28 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.12.0

On 8/9/21 5:35 PM, Franklin, Jason wrote:
> Greetings:
> 
> I discovered today that the GROUPS variable is special in Bash.

It is. For everyone else:

GROUPS An  array  variable  containing  the list of groups of which the
       current user is a member.  Assignments to GROUPS have no effect.
       If  GROUPS is unset, it loses its special properties, even if it
       is subsequently reset.

> 
> I moved some scripts to a new box, and they stopped working.  On this
> box, /bin/sh linked to /bin/bash instead instead of /bin/dash.
> 
> Scripts of of this form...
> 
>   #!/bin/sh
>   GROUPS='foo bar'
>   # do something with $GROUPS here
> 
> had worked because GROUPS had no special meaning under /bin/dash.
> 
> The script is invoked with /bin/sh (linked to /bin/bash), so I had
> expected Bash POSIX compliance to take over.  It did not.

POSIX, which does not specify GROUPS, does not make a difference.

If you would like this to work on dash and bash, unset GROUPS before
trying to assign to it.

> Is this considered a bug?

It's not.

> Should bash, invoked with "--posix" or as "sh", omit the special
> treatment of variables such as GROUPS?

No. Bash does not try to restrict itself to only those things specified
by POSIX.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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