mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
POSIX: 'command': don't disable declaration proprts (re: b9d10c5a)
Following the resolution of Austin Group bug 1393[*] that is set to
be included in the next version of the POSIX standard, the
'command' prefix in POSIX mode (set -o posix) no longer disables
the declaration properties of declaration built-ins.
[*] https://austingroupbugs.net/view.php?id=1393
src/cmd/ksh93/sh/parse.c: lex():
- Skip the 'command' prefix even in POSIX mode so that any
declaration commands prefixed by it are treated as such in xec.c
(sh_exec()).
src/cmd/ksh93/sh/xec.c: sh_exec():
- The foregoing change reintroduced a variant of BUG_CMDSPEXIT: the
shell exits on something like 'command export readonlyvar=foo'.
This now fixes that bug for both POSIX and non-POSIX mode. When
calling nv_setlist() to process true shell assignments, and there
is a 'command' prefix, push a shell context and use sigsetjmp to
intercept any errors in assignments and stop the shell exiting.
src/cmd/ksh93/tests/builtins.sh:
- Borrow the BUG_CMDSPEXIT regression test from modernish and adapt
it for ksh. (I'm the author so yes, I can do this.) Original:
ae8fe9c3/lib/modernish/tst/builtin.t (L80-L109)
This commit is contained in:
parent
1a1e3709c2
commit
d309d604e7
5 changed files with 50 additions and 12 deletions
|
|
@ -1456,7 +1456,7 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
|
|||
lexp->intypeset = 1;
|
||||
key_on = 1;
|
||||
}
|
||||
else if(np==SYSCOMMAND && !sh_isoption(SH_POSIX))
|
||||
else if(np==SYSCOMMAND) /* treat 'command typeset', etc. as declaration command */
|
||||
cmdarg++;
|
||||
else if(np==SYSEXEC || np==SYSREDIR)
|
||||
lexp->inexec = 1;
|
||||
|
|
|
|||
|
|
@ -1172,7 +1172,24 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
flgs |= NV_IDENT;
|
||||
else
|
||||
flgs |= NV_VARNAME;
|
||||
nv_setlist(argp,flgs,tp);
|
||||
/* execute the list of assignments */
|
||||
if((!np || nv_isattr(np,BLT_SPC)) && !command)
|
||||
{
|
||||
/* bare assignment(s) or special builtin, and no 'command' prefix: exit on error */
|
||||
nv_setlist(argp,flgs,tp);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* avoid exit on error from nv_setlist, e.g. read-only variable */
|
||||
struct checkpt *chkp = (struct checkpt*)stakalloc(sizeof(struct checkpt));
|
||||
sh_pushcontext(shp,chkp,SH_JMPCMD);
|
||||
jmpval = sigsetjmp(chkp->buff,1);
|
||||
if(!jmpval)
|
||||
nv_setlist(argp,flgs,tp);
|
||||
sh_popcontext(shp,chkp);
|
||||
if(jmpval) /* error occurred */
|
||||
goto setexit;
|
||||
}
|
||||
if(np==shp->typeinit)
|
||||
shp->typeinit = 0;
|
||||
shp->envlist = argp;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue