[Top][All Lists]

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

Re: temp setting POSIXLY_CORRECT turns alias expansion off

From: L A Walsh
Subject: Re: temp setting POSIXLY_CORRECT turns alias expansion off
Date: Tue, 21 Jan 2020 13:15:16 -0800
User-agent: Thunderbird

On 2020/01/17 06:49, Chet Ramey wrote:
On 1/16/20 2:05 PM, Martijn Dekker wrote:
Op 16-01-20 om 17:02 schreef Chet Ramey:
On 1/15/20 10:24 PM, Martijn Dekker wrote:
When alias expansion is enabled for a script in bash native mode, prefixing POSIXLY_CORRECT=y to any command will turn alias expansion globally off. This is a bug because the assignment should only have effect on that command.
You're probably right, but it's an interesting question.

The idea is that


is essentially equivalent (assuming POSIXLY_CORRECT is not already set) to


and turning off posix mode resets a default environment.
That doesn't make sense. Why should it reset anything? There's no requirement
to reset the environment when turning POSIX_CORRECTLY off.

I think it *should* be essentially equivalent to
     (POSIXLY_CORRECT=y; true)
minus the actual forked subshell of course. But the state after the command should be identical to the state before.

It gets into a larger question about variable setting and unsetting side
effects. POSIXLY_CORRECT is not the only variable for which side effects
   Saying that this bug shouldn't be fixd because all such bugs aren't
not fixed at the same time, doesn't make sense.

Neither, really, does having the default shell settings disable features that that are standard in posix compatible shells. If someone turns on alias expansion, having it turned off with either Env vars being set (or unset), OR turning off posix mode also doesn't make sense. There is no standard requiring options explicitly turned on to be disabled when leaving POSIX mode. It seems the option explicitly regulating a behavior (in this case, alias expansion), should be given first attention if a user has set or unset
that option.

By the same idea, if a user disables alias expansion, turning on posix shouldn't override the first setting. While it is true posix compatible shells should support aliases, I don't
see that as not allowing them to be turned off.

reply via email to

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