Skip to content

Commit

Permalink
Remove problematic check for standards env vars (re: 921bbca)
Browse files Browse the repository at this point in the history
This commit removes the following standards check on init:

	strcmp(astconf("CONFORMANCE",0,0),"standard")==0

This also checks for the POSIXLY_CORRECT variable; the libast
configuration system uses it to set "CONFORMANCE" to "standard",
*but*, only if that parameter wasn't already initialised from the
_AST_FEATURES environment variable (see 'getconf --man').

Problem is, there is a harmful interaction between POSIXLY_CORRECT
and _AST_FEATURES. If the latter exists, it overrides the former.
Not only that, merely querying CONFORMANCE makes astconf create and
export the _AST_FEATURES variable, propagating the current setting
to child ksh processes, which will then ignore POSIXLY_CORRECT.

We could get around this by simply using getenv("POSIXLY_CORRECT").
But then the results may be inconsistent with the AST config state.

The whole thing may not be the best idea anyway. Honouring
POSIXLY_CORRECT at startup introduces a backwards compatibility
issue. Existing scripts or setups may export POSIXLY_CORRECT=y to
put external GNU utilities in standards mode, while still expecting
traditional ksh behaviour from newly initialised shells.

So it's probably better to just get rid of the check. This is not
bash, after all. If ksh is invoked as sh (the POSIX standard
command name), or with '-o posix' on the command line, you get the
standards mode; that ought to be good enough.

src/cmd/ksh93/sh/init.c: sh_init():
- Remove astconf call as per above.
  • Loading branch information
McDutchie committed Sep 5, 2020
1 parent ca9de42 commit 6affd23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/ksh93/sh/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit)
type = sh_type(*argv);
if(type&SH_TYPE_LOGIN)
shp->login_sh = 2;
if(type&SH_TYPE_POSIX || strcmp(astconf("CONFORMANCE",0,0),"standard")==0)
if(type&SH_TYPE_POSIX)
sh_onoption(SH_POSIX);
}
env_init(shp);
Expand Down

0 comments on commit 6affd23

Please sign in to comment.