bug-bash
[Top][All Lists]
Advanced

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

Re: GROUPS


From: Franklin, Jason
Subject: Re: GROUPS
Date: Wed, 11 Aug 2021 20:00:12 -0400
User-agent: Evolution 3.36.5-0ubuntu1

Chet:

My apologies in advance for not responding in thread.  The bug-bash
archive interface doesn't expose the "Message-ID" header anywhere I can
find, and I am not a subscriber.  I suppose I should become one.  :)

> I believe I'd rather have variables behave as they're documented. It's more
> predictable. 

Is it?

The whole point of a standard like POSIX is that I should be able to
write my code in accordance with the standard and have it run on
compliant systems that I may not even be aware of or that might not have
been developed yet.

The standard determines what is "predictable" behavior, not the Bash
documentation.

> That's one of the problems here: the author never intended this script to
> run in any shell other that Debian's dash. If they had, maybe they would
> have tested it on other shells, even other shells that Debian includes.

The author intended for portability and POSIX compliance.  Otherwise,
the script header would not have read "#! /bin/sh".  It runs as expected
on dash and ksh.

POSIX is supposed to enable portability.  Compliant code should run the
same on any compliant interpreter or compiler.  How can I possibly test
on all systems that try to be compliant?  I may not be aware of all of
them or one may not even exist yet.

Requiring someone to test on all possible current and future shells that
claim POSIX-compliance defeats the purpose of a reference.

As an aside:  I believe in thorough testing in as many environments as
feasible!

>     Even then (using either solution), what does a script do if it wants to
>     be invoked as:
> 
>             GROUPS='abelian ...' script [options]
> 
>     ? 
> 
> That case works, see above. Maybe it shouldn't, but it does.

This doesn't work unless it was recently fixed.  A variation does...

bash-5.0$ echo $BASH_VERSION
5.0.17(1)-release
bash-5.0$ GROUPS=FOO bash -c 'echo $GROUPS'
1000
bash-5.0$ GROUPS=FOO bash --posix -c 'echo $GROUPS'
1000
bash-5.0$ env GROUPS=FOO bash -c 'echo $GROUPS'
FOO
bash-5.0$ env GROUPS=FOO bash --posix -c 'echo $GROUPS'
FOO

The same is the case for UID...

bash-5.0$ UID=x bash -c 'echo $UID'
bash: UID: readonly variable
1000

I could be wrong here if this was recently fixed.

> It could have, but I'm not seeing a good enough reason to change it
> 25-30 years in.

I think the result is that this report will surface at regular intervals
for decades to come.

-- 
Jason Franklin




reply via email to

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