From 08714c392096eff9d88ffb96664f0c50266ba7d2 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 22 Jan 2024 20:49:56 +0000 Subject: [PATCH] Yet another round of maintenance and minor cleanups Notable changes: bin/package, src/cmd/INIT/package.sh: - Use POSIX 'hash -r' instead of a dummy assignment to PATH to empty the command lookup hash table. (re: 20f8557c) - Since we will not restore nmake and mamake is working fine for us, eliminate the redundant "make with mamake" announcement. src/cmd/ksh93/sh/xec.c: - De-obfuscate ARG_OPTIMIZE flag use. (re: 9ad96a45) src/lib/libast/features/sys: - Since we always use our own AST spawnveg(3) and not any non-existent native OS implementation thereof, emit the prototype directly instead of probing for the need for it. src/cmd/ksh93/tests/{comvario,enum}.sh: - Move a backported enum test to enum.sh. (re: cfc8744c) --- bin/package | 9 ++---- src/cmd/INIT/mkreq-maplib.sh | 1 - src/cmd/INIT/package.sh | 9 ++---- src/cmd/INIT/proto.sh | 17 +++++++---- src/cmd/ksh93/bltins/read.c | 2 +- src/cmd/ksh93/data/variables.c | 2 +- src/cmd/ksh93/edit/emacs.c | 2 +- src/cmd/ksh93/include/argnod.h | 2 +- src/cmd/ksh93/include/lexstates.h | 2 +- src/cmd/ksh93/include/name.h | 2 +- src/cmd/ksh93/include/shell.h | 2 +- src/cmd/ksh93/include/variables.h | 2 +- src/cmd/ksh93/sh/nvdisc.c | 2 +- src/cmd/ksh93/sh/xec.c | 50 ++++++++++++++----------------- src/cmd/ksh93/tests/comvario.sh | 8 +---- src/cmd/ksh93/tests/coprocess.sh | 6 ++-- src/cmd/ksh93/tests/enum.sh | 19 +++++++----- src/cmd/ksh93/tests/nameref.sh | 2 +- src/cmd/ksh93/tests/types.sh | 2 +- src/lib/libast/features/sys | 2 +- 20 files changed, 68 insertions(+), 75 deletions(-) diff --git a/bin/package b/bin/package index 903552cab483..653d0034010c 100755 --- a/bin/package +++ b/bin/package @@ -115,7 +115,7 @@ command=${0##*/} case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in 0123) USAGE=$' [-? -@(#)$Id: '$command$' (ksh 93u+m) 2024-01-14 $ +@(#)$Id: '$command$' (ksh 93u+m) 2024-01-22 $ ] [-author?Glenn Fowler ] [-author?Contributors to https://github.com/ksh93/ksh] @@ -543,7 +543,7 @@ SEE ALSO pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3) IMPLEMENTATION - version package (ksh 93u+m) 2024-01-14 + version package (ksh 93u+m) 2024-01-22 author Glenn Fowler author Contributors to https://github.com/ksh93/ksh copyright (c) 1994-2012 AT&T Intellectual Property @@ -2375,9 +2375,7 @@ checkaout() # cmd ... fi $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITROOT/$i.c || return test -f $i.o && $exec rm -f $i.o - i=$PATH - PATH=/bin - PATH=$i + hash -r ;; esac done @@ -3086,7 +3084,6 @@ make|view) # build with mamake - note "make with mamake" case $target in '') target="install" ;; esac diff --git a/src/cmd/INIT/mkreq-maplib.sh b/src/cmd/INIT/mkreq-maplib.sh index dc297129b232..579afd173e04 100644 --- a/src/cmd/INIT/mkreq-maplib.sh +++ b/src/cmd/INIT/mkreq-maplib.sh @@ -63,7 +63,6 @@ do # for each lib name also add '-' done # Setup. -set -o noglob trap 'set +o noglob; rm -rf "$req".exe*' 0 ######### Main ########## diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index 903552cab483..653d0034010c 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -115,7 +115,7 @@ command=${0##*/} case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in 0123) USAGE=$' [-? -@(#)$Id: '$command$' (ksh 93u+m) 2024-01-14 $ +@(#)$Id: '$command$' (ksh 93u+m) 2024-01-22 $ ] [-author?Glenn Fowler ] [-author?Contributors to https://github.com/ksh93/ksh] @@ -543,7 +543,7 @@ SEE ALSO pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3) IMPLEMENTATION - version package (ksh 93u+m) 2024-01-14 + version package (ksh 93u+m) 2024-01-22 author Glenn Fowler author Contributors to https://github.com/ksh93/ksh copyright (c) 1994-2012 AT&T Intellectual Property @@ -2375,9 +2375,7 @@ checkaout() # cmd ... fi $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITROOT/$i.c || return test -f $i.o && $exec rm -f $i.o - i=$PATH - PATH=/bin - PATH=$i + hash -r ;; esac done @@ -3086,7 +3084,6 @@ make|view) # build with mamake - note "make with mamake" case $target in '') target="install" ;; esac diff --git a/src/cmd/INIT/proto.sh b/src/cmd/INIT/proto.sh index 6da18071ec70..c0db67a49fb8 100644 --- a/src/cmd/INIT/proto.sh +++ b/src/cmd/INIT/proto.sh @@ -17,16 +17,23 @@ # compiling older AST code (with Mamfiles containing proto commands) using the # current INIT system. This stub ignores all options, then invokes 'cat'. +usage() +{ + echo 'Usage: proto [-dfhinprstvzP+S] [-C directory] [-e package] [-l file]' + echo ' [-o "name='\''value'\'' ..."] [-L file] file ...' + exit 2 +} >&2 + while getopts ':dfhinprstvzPSC:e:l:o:L:' opt do case $opt in + :) usage + ;; \?) case $OPTARG in +) ;; - *) echo "proto: $OPTARG: unknown option" - echo 'Usage: proto [-dfhinprstvzP+S] [-C directory] [-e package] [-l file]' - echo ' [-o "name='\''value'\'' ..."] [-L file] file ...' - exit 2 + *) echo "proto: $OPTARG: unknown option" >&2 + usage ;; - esac >&2 + esac ;; esac done diff --git a/src/cmd/ksh93/bltins/read.c b/src/cmd/ksh93/bltins/read.c index 64debaadc6b7..8482a8b9d340 100644 --- a/src/cmd/ksh93/bltins/read.c +++ b/src/cmd/ksh93/bltins/read.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/data/variables.c b/src/cmd/ksh93/data/variables.c index cf9d8c0259c3..b8764a555c05 100644 --- a/src/cmd/ksh93/data/variables.c +++ b/src/cmd/ksh93/data/variables.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index b90c8a840444..744089cd6f0a 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/include/argnod.h b/src/cmd/ksh93/include/argnod.h index 9cf4ea9e14f8..dbc7661d4f5b 100644 --- a/src/cmd/ksh93/include/argnod.h +++ b/src/cmd/ksh93/include/argnod.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/include/lexstates.h b/src/cmd/ksh93/include/lexstates.h index f133fb6b2822..a4cb0ce9b55c 100644 --- a/src/cmd/ksh93/include/lexstates.h +++ b/src/cmd/ksh93/include/lexstates.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/include/name.h b/src/cmd/ksh93/include/name.h index b641dd6ecfb2..73f77b14fe19 100644 --- a/src/cmd/ksh93/include/name.h +++ b/src/cmd/ksh93/include/name.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/include/shell.h b/src/cmd/ksh93/include/shell.h index 9c228dc24547..2fc39a33c008 100644 --- a/src/cmd/ksh93/include/shell.h +++ b/src/cmd/ksh93/include/shell.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/include/variables.h b/src/cmd/ksh93/include/variables.h index 432b6a5ca2b1..d88d4a5117d4 100644 --- a/src/cmd/ksh93/include/variables.h +++ b/src/cmd/ksh93/include/variables.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/sh/nvdisc.c b/src/cmd/ksh93/sh/nvdisc.c index d52c4f718a38..bc4ff5fe576e 100644 --- a/src/cmd/ksh93/sh/nvdisc.c +++ b/src/cmd/ksh93/sh/nvdisc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index 3c765e4391c9..c3a42222fcb1 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -455,12 +455,6 @@ static int p_switch(struct regnod *reg) } return n; } -# define OPTIMIZE_FLAG (ARG_OPTIMIZE) -# define OPTIMIZE (flags&OPTIMIZE_FLAG) -#else -# define OPTIMIZE_FLAG (0) -# define OPTIMIZE (0) -# define sh_tclear(x) #endif /* SHOPT_OPTIMIZE */ static void out_pattern(Sfio_t *iop, const char *cp, int n) @@ -875,7 +869,7 @@ int sh_exec(const Shnode_t *t, int flags) { int type = t->tre.tretyp; char *com0 = 0; - int errorflg = (flags&sh_state(SH_ERREXIT))|OPTIMIZE; + int errorflg = (flags&sh_state(SH_ERREXIT))|(flags & ARG_OPTIMIZE); int execflg = (flags&sh_state(SH_NOFORK)); int execflg2 = (flags&sh_state(SH_FORKED)); int mainloop = (flags&sh_state(SH_INTERACTIVE)); @@ -922,7 +916,7 @@ int sh_exec(const Shnode_t *t, int flags) type &= (COMMSK|COMSCAN); sh_stats(STAT_SCMDS); error_info.line = t->com.comline-sh.st.firstline; - com = sh_argbuild(&argn,&(t->com),OPTIMIZE); + com = sh_argbuild(&argn,&(t->com),flags & ARG_OPTIMIZE); echeck = 1; if(t->tre.tretyp&COMSCAN) { @@ -1231,7 +1225,7 @@ int sh_exec(const Shnode_t *t, int flags) bp->data = t->com.comstate; bp->sigset = 0; bp->notify = 0; - bp->flags = (OPTIMIZE!=0); + bp->flags = ((flags & ARG_OPTIMIZE)!=0); if(sh.subshell && nv_isattr(np,BLT_NOSFIO)) sh_subtmpfile(); if(argn) @@ -1394,7 +1388,7 @@ int sh_exec(const Shnode_t *t, int flags) } namespace = enter_namespace(namespace); #endif /* SHOPT_NAMESPACE */ - sh_funct(np,argn,com,t->com.comset,(flags&~OPTIMIZE_FLAG)); + sh_funct(np,argn,com,t->com.comset,(flags&~ARG_OPTIMIZE)); } #if SHOPT_NAMESPACE enter_namespace(namespace); @@ -1763,7 +1757,7 @@ int sh_exec(const Shnode_t *t, int flags) */ case TPAR: echeck = 1; - flags &= ~OPTIMIZE_FLAG; + flags &= ~ARG_OPTIMIZE; if(!sh.subshell && !sh.st.trapdontexec && (flags&sh_state(SH_NOFORK))) { /* This is the last command, so avoid creating a subshell */ @@ -1915,7 +1909,7 @@ int sh_exec(const Shnode_t *t, int flags) { do { - sh_exec(t->lst.lstlef,errorflg|OPTIMIZE); + sh_exec(t->lst.lstlef,errorflg|(flags & ARG_OPTIMIZE)); t = t->lst.lstrit; } while(t->tre.tretyp == TLST); @@ -1929,7 +1923,7 @@ int sh_exec(const Shnode_t *t, int flags) case TAND: if(type&TTEST) skipexitset++; - if(sh_exec(t->lst.lstlef,OPTIMIZE)==0) + if(sh_exec(t->lst.lstlef, flags & ARG_OPTIMIZE)==0) sh_exec(t->lst.lstrit,flags); break; @@ -1939,7 +1933,7 @@ int sh_exec(const Shnode_t *t, int flags) case TORF: if(type&TTEST) skipexitset++; - if(sh_exec(t->lst.lstlef,OPTIMIZE)!=0) + if(sh_exec(t->lst.lstlef, flags & ARG_OPTIMIZE)!=0) sh_exec(t->lst.lstrit,flags); break; @@ -1951,7 +1945,7 @@ int sh_exec(const Shnode_t *t, int flags) char **args; int nargs; Namval_t *np; - int flag = errorflg|OPTIMIZE_FLAG; + int flag = errorflg|ARG_OPTIMIZE; struct dolnod *argsav = NULL; struct comnod *tp; char *cp, *trap, *null_pointer = NULL; @@ -2048,7 +2042,7 @@ int sh_exec(const Shnode_t *t, int flags) sh_debug(trap,NULL,NULL,av,0); } sh_exec(t->for_.fortre,flag); - flag &= ~OPTIMIZE_FLAG; + flag &= ~ARG_OPTIMIZE; if(t->tre.tretyp&COMSCAN) { if((cp=nv_getval(sh_scoped(REPLYNOD))) && *cp==0) @@ -2085,7 +2079,7 @@ int sh_exec(const Shnode_t *t, int flags) case TWH: { volatile int r=0; - int first = OPTIMIZE_FLAG; + int first = ARG_OPTIMIZE; Shnode_t *tt = t->wh.whtre; #if SHOPT_FILESCAN Sfio_t *iop=0; @@ -2138,7 +2132,7 @@ int sh_exec(const Shnode_t *t, int flags) if(sh.st.breakcnt==0 && t->wh.whinc) sh_exec((Shnode_t*)t->wh.whinc,first); first = 0; - errorflg &= ~OPTIMIZE_FLAG; + errorflg &= ~ARG_OPTIMIZE; #if SHOPT_FILESCAN sh.offsets[0] = -1; sh.offsets[1] = 0; @@ -2182,7 +2176,7 @@ int sh_exec(const Shnode_t *t, int flags) error_info.line = t->ar.arline-sh.st.firstline; arg[0] = "(("; if(!(t->ar.arexpr->argflag&ARG_RAW)) - arg[1] = sh_macpat(t->ar.arexpr,OPTIMIZE|ARG_ARITH); + arg[1] = sh_macpat(t->ar.arexpr,(flags & ARG_OPTIMIZE)|ARG_ARITH); else arg[1] = t->ar.arexpr->argval; arg[2] = "))"; @@ -2205,7 +2199,7 @@ int sh_exec(const Shnode_t *t, int flags) * Conditional block: if ... fi */ case TIF: - if(sh_exec(t->if_.iftre,OPTIMIZE)==0) + if(sh_exec(t->if_.iftre, flags & ARG_OPTIMIZE)==0) sh_exec(t->if_.thtre,flags); else if(t->if_.eltre) sh_exec(t->if_.eltre, flags); @@ -2219,7 +2213,7 @@ int sh_exec(const Shnode_t *t, int flags) case TSW: { const int eflag = flags & sh_state(SH_ERREXIT); - char *r = sh_macpat(t->sw.swarg,OPTIMIZE); + char *r = sh_macpat(t->sw.swarg, flags & ARG_OPTIMIZE); error_info.line = t->sw.swline - sh.st.firstline; if(sh.st.trap[SH_DEBUGTRAP]) { @@ -2239,7 +2233,7 @@ int sh_exec(const Shnode_t *t, int flags) const unsigned char raw = rex->argflag & ARG_RAW; char *s; if(rex->argflag&ARG_MAC) - s = sh_macpat(rex,OPTIMIZE|ARG_EXP); + s = sh_macpat(rex,(flags & ARG_OPTIMIZE)|ARG_EXP); else s = rex->argval; if(raw && strcmp(r,s)==0 || !raw && strmatch(r,s)) @@ -2274,7 +2268,7 @@ int sh_exec(const Shnode_t *t, int flags) #endif if(type!=TTIME) { - sh_exec(t->par.partre,OPTIMIZE); + sh_exec(t->par.partre, flags & ARG_OPTIMIZE); sh.exitval = !sh.exitval; break; } @@ -2294,7 +2288,7 @@ int sh_exec(const Shnode_t *t, int flags) } #endif sh_onstate(SH_TIMING); - sh_exec(t->par.partre,sh_isstate(SH_ERREXIT)|OPTIMIZE); + sh_exec(t->par.partre,sh_isstate(SH_ERREXIT)|(flags & ARG_OPTIMIZE)); if(!timer_on) sh_offstate(SH_TIMING); } @@ -2535,7 +2529,7 @@ int sh_exec(const Shnode_t *t, int flags) echeck = 1; if((type&TPAREN)==TPAREN) { - sh_exec(t->lst.lstlef,OPTIMIZE); + sh_exec(t->lst.lstlef, flags & ARG_OPTIMIZE); n = !sh.exitval; } else @@ -2545,9 +2539,9 @@ int sh_exec(const Shnode_t *t, int flags) char *trap; char *argv[6]; n = type>>TSHIFT; - left = sh_macpat(&(t->lst.lstlef->arg),OPTIMIZE); + left = sh_macpat(&(t->lst.lstlef->arg), flags & ARG_OPTIMIZE); if(type&TBINARY) - right = sh_macpat(&(t->lst.lstrit->arg),((n==TEST_PEQ||n==TEST_PNE)?ARG_EXP:0)|OPTIMIZE); + right = sh_macpat(&(t->lst.lstrit->arg),((n==TEST_PEQ||n==TEST_PNE)?ARG_EXP:0)|(flags & ARG_OPTIMIZE)); if(trap=sh.st.trap[SH_DEBUGTRAP]) argv[0] = (type&TNEGATE)?((char*)e_tstbegin):"[["; if(sh_isoption(SH_XTRACE)) @@ -2634,7 +2628,7 @@ int sh_exec(const Shnode_t *t, int flags) } if(!skipexitset) exitset(); - if(!(OPTIMIZE)) + if(!(flags & ARG_OPTIMIZE)) { if(sav != stkptr(sh.stk,0)) stkset(sh.stk,sav,0); diff --git a/src/cmd/ksh93/tests/comvario.sh b/src/cmd/ksh93/tests/comvario.sh index 58ade180cd05..698bc45bc62b 100755 --- a/src/cmd/ksh93/tests/comvario.sh +++ b/src/cmd/ksh93/tests/comvario.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-2012 AT&T Intellectual Property # -# Copyright (c) 2020-2022 Contributors to ksh 93u+m # +# Copyright (c) 2020-2024 Contributors to ksh 93u+m # # and is licensed under the # # Eclipse Public License, Version 2.0 # # # @@ -646,11 +646,5 @@ test_read_type_crash test_read_C_into_array test_read_C_special_shell_keywords -unset bar -enum bool=(false true) -bool -a bar -bar[3]=true -[[ $((5+bar[3])) != 6 ]] && err_exit '$((5+bar[3])) should be 6' - # tests done exit $((Errors<125?Errors:125)) diff --git a/src/cmd/ksh93/tests/coprocess.sh b/src/cmd/ksh93/tests/coprocess.sh index ef18e8109953..18b524189a69 100755 --- a/src/cmd/ksh93/tests/coprocess.sh +++ b/src/cmd/ksh93/tests/coprocess.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-2012 AT&T Intellectual Property # -# Copyright (c) 2020-2022 Contributors to ksh 93u+m # +# Copyright (c) 2020-2024 Contributors to ksh 93u+m # # and is licensed under the # # Eclipse Public License, Version 2.0 # # # @@ -156,7 +156,7 @@ do integer i for ((i = 1; i <= N; i++)) do print $i |& - sleep 0.001 + sleep 0.01 r=$r$($cat <&p) wait $! done @@ -166,7 +166,7 @@ do ( $cat |& - sleep 0.001 + sleep 0.01 exec 6>&p print -u6 ok exec 6>&- diff --git a/src/cmd/ksh93/tests/enum.sh b/src/cmd/ksh93/tests/enum.sh index 199896bb4df3..2d293c8a3395 100755 --- a/src/cmd/ksh93/tests/enum.sh +++ b/src/cmd/ksh93/tests/enum.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-2012 AT&T Intellectual Property # -# Copyright (c) 2020-2023 Contributors to ksh 93u+m # +# Copyright (c) 2020-2024 Contributors to ksh 93u+m # # and is licensed under the # # Eclipse Public License, Version 2.0 # # # @@ -167,29 +167,34 @@ exp=': trap: is a special shell builtin' # ====== # Various tests backported from ksh93v- for enum type arrays. -enum bool=(false true) -bool -A a=( [2]=true [4]=false ) -exp=true +Bool_t -A a=( [2]=true [4]=false ) +exp=True got=${a[2]} [[ $got == $exp ]] || err_exit 'associative array assignment failure when using enums' \ "(expected $(printf %q "$exp"); got $(printf %q "$got"))" exp=2 got=${#a[@]} -[[ $got == $exp ]] || err_exit 'bool -A a should only have two elements' \ +[[ $got == $exp ]] || err_exit 'Bool_t -A a should only have two elements' \ "(expected $(printf %q "$exp"); got $(printf %q "$got"))" -bool -a bia +Bool_t -a bia (( bia[4]=false )) [[ ${bia[3]} ]] && err_exit 'empty index array element should not produce a value' (( bia[3] == 0 )) || err_exit 'empty index array element should be numerically 0' -bool -A baa +Bool_t -A baa (( baa[4]=false )) [[ ${baa[3]} ]] && err_exit 'empty associative array element should not produce a value' (( baa[3] == 0 )) || err_exit 'empty associative array element should be numerically 0' +unset bar +Bool_t -a bar +bar[3]=true +[[ $((5+bar[3])) != 6 ]] && err_exit '$((5+bar[3])) should be 6' + # ====== # https://github.com/ksh93/ksh/issues/638 enum colors=(red green blue) +unset bar typeset -a \[colors] bar bar[blue]=test exp="typeset -a '[colors]' bar=([blue]=test)" diff --git a/src/cmd/ksh93/tests/nameref.sh b/src/cmd/ksh93/tests/nameref.sh index b8a89aefe29f..dd901977a3d7 100755 --- a/src/cmd/ksh93/tests/nameref.sh +++ b/src/cmd/ksh93/tests/nameref.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-2012 AT&T Intellectual Property # -# Copyright (c) 2020-2023 Contributors to ksh 93u+m # +# Copyright (c) 2020-2024 Contributors to ksh 93u+m # # and is licensed under the # # Eclipse Public License, Version 2.0 # # # diff --git a/src/cmd/ksh93/tests/types.sh b/src/cmd/ksh93/tests/types.sh index 0853a58c164b..944d51837427 100755 --- a/src/cmd/ksh93/tests/types.sh +++ b/src/cmd/ksh93/tests/types.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-2012 AT&T Intellectual Property # -# Copyright (c) 2020-2023 Contributors to ksh 93u+m # +# Copyright (c) 2020-2024 Contributors to ksh 93u+m # # and is licensed under the # # Eclipse Public License, Version 2.0 # # # diff --git a/src/lib/libast/features/sys b/src/lib/libast/features/sys index d6594fbe0bdc..79fcda7e3cf1 100644 --- a/src/lib/libast/features/sys +++ b/src/lib/libast/features/sys @@ -190,7 +190,6 @@ extern setpgid int (pid_t, pid_t) extern setsid pid_t (void) extern setuid int (uid_t) extern sleep unsigned (unsigned int) -extern spawnveg pid_t (const char*, char* const[], char* const[], pid_t, int) extern srand void (unsigned int) extern strcasecmp int (const char*, const char*) extern strcat char* (char*, const char*) @@ -223,5 +222,6 @@ extern wcstombs size_t (char*, const wchar_t*, size_t) extern wctomb int (char*, wchar_t) extern write ssize_t (int, const void*, size_t) +print extern pid_t spawnveg(const char*, char* const[], char* const[], pid_t, int); print #undef extern print #include