mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-12 19:22:41 +00:00
More misc. tweaks and cleanups
Notable changes:
.github/workflows/ci.yml:
- Run 'bin/package test' on the github runner so we test iffe too.
src/cmd/ksh93/sh/subshell.c:
- sh_assignok was usually called like 'np = sh_assignok(np,0)'. But
the function never changes np, it just returns the np value
passed to it, so the assignment is pointless and that function
can be changed to a void.
src/cmd/ksh93/sh/fault.c: sh_fault():
- Remove check for sh.subshell after sh_isstate(SH_INTERACTIVE). As
of 48ba6964
, it is never set in subshells.
This commit is contained in:
parent
adc6a64b82
commit
064baa372e
24 changed files with 47 additions and 51 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -19,7 +19,7 @@ jobs:
|
|||
export TZ=UTC
|
||||
ulimit -n 1024
|
||||
: default regression tests &&
|
||||
script -q -e -c "bin/shtests" &&
|
||||
script -q -e -c "bin/package test" &&
|
||||
: regression tests with OS-provided multibyte locales &&
|
||||
LANG=nl_NL.UTF-8 script -q -e -c "bin/shtests --locale --nocompile" &&
|
||||
LANG=ja_JP.SJIS script -q -e -c "bin/shtests --locale --nocompile" &&
|
||||
|
|
|
@ -6,7 +6,6 @@ note * Mamfiles are processed by mamake (src/cmd/INIT/mamake.c); we added
|
|||
note * indentation to improve readability. The language is documented in
|
||||
note * src/cmd/INIT/README-mamake.md.
|
||||
note *
|
||||
note source level :MAKE: equivalent
|
||||
make test
|
||||
make install
|
||||
make all
|
||||
|
|
|
@ -32,7 +32,7 @@ ksh 93u+m made a few minor changes to `mamake` that make it easier to maintain M
|
|||
* Unrecognized commands and rule attributes throw an error instead of being silently ignored.
|
||||
* Fixed some crashing bugs and memory leaks.
|
||||
|
||||
### Comments and unrecognized commands ###
|
||||
## Commands ##
|
||||
|
||||
MAM commands have the following basic form:
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ note * Mamfiles are processed by mamake (src/cmd/INIT/mamake.c); we added
|
|||
note * indentation to improve readability. The language is documented in
|
||||
note * src/cmd/INIT/README-mamake.md.
|
||||
note *
|
||||
note component level :MAKE: equivalent
|
||||
make test
|
||||
make install
|
||||
make all
|
||||
|
|
|
@ -104,8 +104,8 @@ int b_cd(int argc, char *argv[],Shbltin_t *context)
|
|||
if(sh.subshell)
|
||||
{
|
||||
/* clone $OLDPWD and $PWD into the subshell's scope */
|
||||
opwdnod = sh_assignok(opwdnod,1);
|
||||
pwdnod = sh_assignok(pwdnod,1);
|
||||
sh_assignok(opwdnod,1);
|
||||
sh_assignok(pwdnod,1);
|
||||
}
|
||||
if(argc==2)
|
||||
dir = sh_substitute(oldpwd,dir,argv[1]);
|
||||
|
|
|
@ -832,10 +832,8 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp
|
|||
*/
|
||||
if((flag&NV_ARRAY) && !sh.envlist && !nv_isnull(np))
|
||||
sh_subfork(); /* work around https://github.com/ksh93/ksh/issues/409 */
|
||||
else if(!nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np))
|
||||
np=sh_assignok(np,2);
|
||||
else
|
||||
np=sh_assignok(np,0);
|
||||
sh_assignok(np, !nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np));
|
||||
}
|
||||
if(iarray)
|
||||
{
|
||||
|
@ -939,7 +937,7 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp
|
|||
if(np==SH_LEVELNOD)
|
||||
return(r);
|
||||
if(sh.subshell)
|
||||
sh_assignok(np,2);
|
||||
sh_assignok(np,1);
|
||||
if(troot!=sh.var_tree)
|
||||
nv_setattr(np,newflag&~NV_ASSIGN);
|
||||
else
|
||||
|
@ -1390,10 +1388,7 @@ static int unall(int argc, char **argv, register Dt_t *troot)
|
|||
* Create local scope for virtual subshell. Variables with discipline functions
|
||||
* (LC_*, LINENO, etc.) need to be cloned, as moving them will remove the discipline.
|
||||
*/
|
||||
if(!nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np))
|
||||
np=sh_assignok(np,2);
|
||||
else
|
||||
np=sh_assignok(np,0);
|
||||
sh_assignok(np, !nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np));
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/***********************************************************************
|
||||
* *
|
||||
* This software is part of the ast package *
|
||||
* Copyright (c) 1982-2012 AT&T Intellectual Property *
|
||||
* Copyright (c) 1982-2014 AT&T Intellectual Property *
|
||||
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
|
||||
* and is licensed under the *
|
||||
* Eclipse Public License, Version 1.0 *
|
||||
|
|
|
@ -112,7 +112,7 @@ extern struct dolnod *sh_argnew(char*[],struct dolnod**);
|
|||
extern void *sh_argopen(void);
|
||||
extern struct argnod *sh_argprocsub(struct argnod*);
|
||||
extern void sh_argreset(struct dolnod*,struct dolnod*);
|
||||
extern Namval_t *sh_assignok(Namval_t*,int);
|
||||
extern void sh_assignok(Namval_t*,int);
|
||||
extern struct dolnod *sh_arguse(void);
|
||||
extern char *sh_checkid(char*,char*);
|
||||
extern void sh_chktrap(void);
|
||||
|
|
|
@ -277,7 +277,7 @@ struct Shell_s
|
|||
Sfio_t *heredocs; /* current here-doc temp file */
|
||||
Sfio_t *funlog; /* for logging function definitions */
|
||||
int **fdptrs; /* pointer to file numbers */
|
||||
char *lastarg;
|
||||
char *lastarg; /* $_ */
|
||||
int path_err; /* last error on path search */
|
||||
Dt_t *var_base; /* global level variables */
|
||||
Dt_t *fun_base; /* global level functions */
|
||||
|
|
|
@ -1198,7 +1198,7 @@ Namval_t *nv_putsub(Namval_t *np,register char *sp,register long mode)
|
|||
if(size==0 && !(mode&ARRAY_FILL))
|
||||
return(NIL(Namval_t*));
|
||||
if(sh.subshell)
|
||||
np = sh_assignok(np,1);
|
||||
sh_assignok(np,1);
|
||||
ap = array_grow(np, ap,size);
|
||||
}
|
||||
ap->header.nelem &= ~ARRAY_UNDEF;
|
||||
|
@ -1232,7 +1232,7 @@ Namval_t *nv_putsub(Namval_t *np,register char *sp,register long mode)
|
|||
else if(!(sp=(char*)ap->val[size].cp) || sp==Empty)
|
||||
{
|
||||
if(sh.subshell)
|
||||
np = sh_assignok(np,1);
|
||||
sh_assignok(np,1);
|
||||
if(ap->header.nelem&ARRAY_TREE)
|
||||
{
|
||||
char *cp;
|
||||
|
|
|
@ -123,7 +123,7 @@ void sh_fault(register int sig)
|
|||
if(flag&SH_SIGDONE)
|
||||
{
|
||||
void *ptr=0;
|
||||
if((flag&SH_SIGINTERACTIVE) && sh_isstate(SH_INTERACTIVE) && !sh_isstate(SH_FORKED) && ! sh.subshell)
|
||||
if((flag&SH_SIGINTERACTIVE) && sh_isstate(SH_INTERACTIVE) && !sh_isstate(SH_FORKED))
|
||||
{
|
||||
/* check for TERM signal between fork/exec */
|
||||
if(sig==SIGTERM && job.in_critical)
|
||||
|
|
|
@ -2014,7 +2014,7 @@ retry2:
|
|||
if(np)
|
||||
{
|
||||
if(sh.subshell)
|
||||
np = sh_assignok(np,1);
|
||||
sh_assignok(np,1);
|
||||
nv_putval(np,argp,0);
|
||||
v = nv_getval(np);
|
||||
nulflg = 0;
|
||||
|
|
|
@ -536,7 +536,7 @@ static void exfile(register Sfio_t *iop,register int fno)
|
|||
{
|
||||
buff.mode = SH_JMPERREXIT;
|
||||
#ifdef DEBUG
|
||||
errormsg(SH_DICT,ERROR_warn(0),"%d: mode changed to JMP_EXIT",sh.current_pid);
|
||||
errormsg(SH_DICT,ERROR_warn(0),"%d: mode changed to SH_JMPERREXIT",sh.current_pid);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1592,7 +1592,7 @@ void nv_putval(register Namval_t *np, const char *string, int flags)
|
|||
/* Create a local scope when inside of a virtual subshell */
|
||||
sh.argaddr = 0;
|
||||
if(sh.subshell && !nv_local && !(flags&NV_RDONLY))
|
||||
np = sh_assignok(np,1);
|
||||
sh_assignok(np,1);
|
||||
/* Export the variable if 'set -o allexport' is enabled */
|
||||
if(sh_isoption(SH_ALLEXPORT))
|
||||
{
|
||||
|
@ -2492,7 +2492,7 @@ void _nv_unset(register Namval_t *np,int flags)
|
|||
goto done;
|
||||
}
|
||||
if(sh.subshell)
|
||||
np = sh_assignok(np,0);
|
||||
sh_assignok(np,0);
|
||||
nv_offattr(np,NV_NODISC);
|
||||
if(np->nvfun && !nv_isref(np))
|
||||
{
|
||||
|
|
|
@ -1581,7 +1581,7 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
|
|||
type = NV_ARRAY;
|
||||
if(tok==LABLSYM && (flag&SH_ASSIGN))
|
||||
lexp->token = tok = 0;
|
||||
if((tok==IPROCSYM || tok==OPROCSYM))
|
||||
if(tok==IPROCSYM || tok==OPROCSYM)
|
||||
{
|
||||
procsub:
|
||||
argp = process_sub(lexp,tok);
|
||||
|
@ -1745,7 +1745,7 @@ static int skipnl(Lex_t *lexp,int flag)
|
|||
}
|
||||
|
||||
/*
|
||||
* check for and process and i/o redirections
|
||||
* check for and process I/O redirections
|
||||
* if flag>0 then an alias can be in the next word
|
||||
* if flag<0 only one redirection will be processed
|
||||
*/
|
||||
|
|
|
@ -236,7 +236,7 @@ char *path_pwd(void)
|
|||
if(cp)
|
||||
{
|
||||
if(sh.subshell)
|
||||
pwdnod = sh_assignok(pwdnod,1);
|
||||
sh_assignok(pwdnod,1);
|
||||
nv_putval(pwdnod,cp,NV_RDONLY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ void sh_save_rand_seed(struct rand *rp, int reseed)
|
|||
* add == 0: Move the node pointer from the parent shell to the current virtual subshell.
|
||||
* add == 1: Create a copy of the node pointer in the current virtual subshell.
|
||||
*/
|
||||
Namval_t *sh_assignok(register Namval_t *np,int add)
|
||||
void sh_assignok(Namval_t *np,int add)
|
||||
{
|
||||
register Namval_t *mp;
|
||||
register struct Link *lp;
|
||||
|
@ -275,18 +275,18 @@ Namval_t *sh_assignok(register Namval_t *np,int add)
|
|||
* Also, ${.sh.level} (SH_LEVELNOD) is handled specially and is not scoped in virtual subshells.
|
||||
*/
|
||||
if(subshell_noscope || sh.subshare || np==SH_LEVELNOD)
|
||||
return(np);
|
||||
return;
|
||||
if((ap=nv_arrayptr(np)) && (mp=nv_opensub(np)))
|
||||
{
|
||||
sh.last_root = ap->table;
|
||||
sh_assignok(mp,add);
|
||||
if(!add || array_assoc(ap))
|
||||
return(np);
|
||||
return;
|
||||
}
|
||||
for(lp=sp->svar; lp;lp = lp->next)
|
||||
{
|
||||
if(lp->node==np)
|
||||
return(np);
|
||||
return;
|
||||
}
|
||||
/* first two pointers use linkage from np */
|
||||
lp = (struct Link*)sh_malloc(sizeof(*np)+2*sizeof(void*));
|
||||
|
@ -323,7 +323,6 @@ Namval_t *sh_assignok(register Namval_t *np,int add)
|
|||
nv_onattr(mp,NV_IDENT);
|
||||
nv_clone(np,mp,(add?(nv_isnull(np)?0:NV_NOFREE)|NV_ARRAY:NV_MOVE));
|
||||
sh.subshell = save;
|
||||
return(np);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -893,10 +893,10 @@ static int check_exec_optimization(int type, int execflg, int execflg2, struct i
|
|||
*/
|
||||
int sh_exec(register const Shnode_t *t, int flags)
|
||||
{
|
||||
Stk_t *stkp = sh.stk;
|
||||
sh_sigcheck();
|
||||
if(t && sh.st.breakcnt==0 && !sh_isoption(SH_NOEXEC))
|
||||
{
|
||||
Stk_t *stkp = sh.stk;
|
||||
register int type = t->tre.tretyp;
|
||||
register char *com0 = 0;
|
||||
int errorflg = (flags&sh_state(SH_ERREXIT))|OPTIMIZE;
|
||||
|
@ -3463,8 +3463,6 @@ static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid)
|
|||
signal(SIGTSTP,SIG_DFL);
|
||||
jobwasset++;
|
||||
}
|
||||
#endif /* _use_ntfork_tcpgrp */
|
||||
#if _use_ntfork_tcpgrp
|
||||
if(sh_isstate(SH_MONITOR) && job.jobcontrol)
|
||||
{
|
||||
if(job.curpgid==0)
|
||||
|
|
|
@ -36,7 +36,7 @@ fi
|
|||
# use the same pseudorandom seed as the main shell.
|
||||
# https://github.com/ksh93/ksh/issues/285
|
||||
# These tests sometimes fail as duplicate numbers can occur randomly, so try up to $N times.
|
||||
integer N=3 i rand1 rand2
|
||||
integer N=5 i rand1 rand2
|
||||
RANDOM=123
|
||||
function rand_print {
|
||||
ulimit -t unlimited 2> /dev/null
|
||||
|
@ -81,7 +81,7 @@ do ( echo $RANDOM & ) >|r1
|
|||
do ((giveup)) && break
|
||||
done
|
||||
if ((giveup))
|
||||
then err_exit "Test 4: ( echo $RANDOM & ) does not write output"
|
||||
then err_exit 'Test 4: ( echo $RANDOM & ) does not write output'
|
||||
fi
|
||||
kill $! 2>/dev/null
|
||||
trap - USR1
|
||||
|
|
|
@ -6,7 +6,6 @@ note * Mamfiles are processed by mamake (src/cmd/INIT/mamake.c); we added
|
|||
note * indentation to improve readability. The language is documented in
|
||||
note * src/cmd/INIT/README-mamake.md.
|
||||
note *
|
||||
note component level :MAKE: equivalent
|
||||
make test
|
||||
make install
|
||||
make all
|
||||
|
|
|
@ -25,10 +25,10 @@ tst ptr_void note{ standard C void* ok }end compile{
|
|||
|
||||
cat{
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-register"
|
||||
#pragma clang diagnostic ignored "-Wmacro-redefined"
|
||||
#pragma clang diagnostic ignored "-Wparentheses"
|
||||
#pragma clang diagnostic ignored "-Wstring-plus-int"
|
||||
#pragma clang diagnostic ignored "-Wunused-value"
|
||||
#pragma GCC diagnostic ignored "-Wunused-result"
|
||||
|
||||
/* AST backwards compatibility macros */
|
||||
#undef _NIL_
|
||||
|
|
|
@ -242,19 +242,26 @@ ERROR_OPTIONS="system"
|
|||
provides debugging message macros when
|
||||
.L DEBUG
|
||||
or
|
||||
.L _TRACE_
|
||||
.L _BLD_DEBUG
|
||||
are defined
|
||||
.RL ( _TRACE_
|
||||
.RL ( _BLD_DEBUG
|
||||
is defined by
|
||||
.I makerules
|
||||
when
|
||||
.L CCFLAGS
|
||||
contains
|
||||
.LR \-g ).
|
||||
the
|
||||
.IR Mamfile s
|
||||
when the
|
||||
.L \-G
|
||||
a.k.a.
|
||||
.L \-\-debug\-symbols
|
||||
option is passed to
|
||||
.BR mamake (1),
|
||||
which the
|
||||
.BR package (1)
|
||||
command does automatically when given the argument
|
||||
.LR debug=1 ).
|
||||
All of the macros expand to nothing when both
|
||||
.L DEBUG
|
||||
and
|
||||
.L _TRACE_
|
||||
.L _BLD_DEBUG
|
||||
are not defined.
|
||||
Otherwise
|
||||
.L debug
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* *
|
||||
* This software is part of the ast package *
|
||||
* Copyright (c) 1985-2012 AT&T Intellectual Property *
|
||||
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
|
||||
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
|
||||
* and is licensed under the *
|
||||
* Eclipse Public License, Version 1.0 *
|
||||
* by AT&T Intellectual Property *
|
||||
|
@ -76,7 +76,8 @@ pathpath_20100601(const char* p, const char* a, int mode, register char* path, s
|
|||
{
|
||||
if (*p != '/' && (mode & PATH_ABSOLUTE))
|
||||
{
|
||||
getcwd(buf, sizeof(buf));
|
||||
if(!getcwd(buf, sizeof(buf)))
|
||||
return (char*)0;
|
||||
s = buf + strlen(buf);
|
||||
sfsprintf(s, sizeof(buf) - (s - buf), "/%s", p);
|
||||
if (path != buf)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* *
|
||||
* This software is part of the ast package *
|
||||
* Copyright (c) 1992-2011 AT&T Intellectual Property *
|
||||
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
|
||||
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
|
||||
* and is licensed under the *
|
||||
* Eclipse Public License, Version 1.0 *
|
||||
* by AT&T Intellectual Property *
|
||||
|
@ -52,7 +52,6 @@
|
|||
#define eol(c) ((c)&WC_NL)
|
||||
#define mbc(c) ((c)&WC_MB)
|
||||
#define spc(c) ((c)&WC_SP)
|
||||
#define mb2wc(w,p,n) (*ast.mb_towc)(&w,(char*)p,n)
|
||||
|
||||
Wc_t* wc_init(int mode)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue