Here is a patch to keep ksh up to speed with master, also, I have attached logs of valgrind and gdb for running ./dtksh examples/CallDataTest4, it seems that variables without a period in them work fine, but for some reason a period causes it to crash (at this line specifically:)
echo "CallData.Reason = "${CB_CALL_DATA.REASON} Thank you for your time, -Chase
From 2c283252ebc866d2224940d852728984bb37b01d Mon Sep 17 00:00:00 2001 From: Chase <nicetry...@protonmail.ch> Date: Thu, 10 Sep 2020 21:58:26 -0500 Subject: [PATCH] ksh: update to commit 092b90 --- cde/programs/dtksh/builtins.c | 77 ++++++----------- cde/programs/dtksh/init.c | 157 +++++++++++++--------------------- cde/programs/dtksh/ksh93 | 2 +- 3 files changed, 86 insertions(+), 150 deletions(-) diff --git a/cde/programs/dtksh/builtins.c b/cde/programs/dtksh/builtins.c index a78210c1..2e59506c 100644 --- a/cde/programs/dtksh/builtins.c +++ b/cde/programs/dtksh/builtins.c @@ -68,7 +68,6 @@ /* * IMPORTANT: The order of these struct members must be synchronous * with the offsets on the macros defined in include/builtins.h! - * The order up through "local" is significant. */ const struct shtable3 shtab_builtins[] = { @@ -95,9 +94,6 @@ const struct shtable3 shtab_builtins[] = ".", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(dot_cmd), "source", NV_BLTIN|BLT_ENV, bltin(dot_cmd), "return", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return), -#if SHOPT_BASH - "local", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(typeset), -#endif /* * Builtins without offset macros in include/builtins.h follow. */ @@ -178,7 +174,7 @@ const struct shtable3 shtab_builtins[] = "__regress__", NV_BLTIN|BLT_ENV, bltin(__regress__), #endif #ifdef BUILD_DTKSH - DTK_EXTRA_TABLE + DTK_EXTRA_TABLE DTK_EXTRA_TABLE2 DTK_TK_EXTRA_TABLE DTK_TK_LIST_TABLE @@ -241,13 +237,6 @@ const char sh_set[] = "[+gmacs?Enables/disables \bgmacs\b editing mode. \bgmacs\b " "editing mode is the same as \bemacs\b editing mode " "except for the handling of \b^T\b.]" -#if SHOPT_BASH - "[+hashall?Equivalent to \b-h\b and \b-o trackall\b. Available " - "in bash compatibility mode only.]" - "[+history?Enable command history. Available in bash " - "compatibility mode only. On by default in interactive " - "shells.]" -#endif #if SHOPT_HISTEXPAND "[+histexpand?Equivalent to \b-H\b.]" #endif @@ -268,20 +257,12 @@ const char sh_set[] = "compatibility.]" "[+notify?Equivalent to \b-b\b.]" "[+nounset?Equivalent to \b-u\b.]" -#if SHOPT_BASH - "[+onecmd?Equivalent to \b-t\b. Available in bash compatibility " - "mode only.]" - "[+physical?Equivalent to \b-P\b. Available in bash " - "compatibility mode only.]" - "[+posix?Turn on POSIX compatibility. Available in bash " - "compatibility mode only. Bash in POSIX mode is not the " - "same as ksh.]" -#endif "[+pipefail?A pipeline will not complete until all components " "of the pipeline have completed, and the exit status " "of the pipeline will be the value of the last " "command to exit with non-zero exit status, or will " "be zero if all commands return zero exit status.]" + "[+posix?Enable full POSIX standard compliance mode.]" "[+privileged?Equivalent to \b-p\b.]" "[+rc?Do not run the \b.kshrc\b file for interactive shells.]" "[+showme?Simple commands preceded by a \b;\b will be traced " @@ -310,9 +291,6 @@ const char sh_set[] = "[x?Execution trace. The shell will display each command after all " "expansion and before execution preceded by the expanded value " "of the \bPS4\b parameter.]" -#if SHOPT_BASH - "\fbash1\f" -#endif #if SHOPT_BRACEPAT "[B?Enable {...} group expansion. On by default.]" #endif @@ -348,7 +326,7 @@ const char sh_optcont[] = "[-1c?\n@(#)$Id: continue (AT&T Research) 1999-04-07 $\n]" USAGE_LICENSE "[+NAME?continue - continue execution at top of the loop]" -"[+DESCRIPTION?\bcontinue\b is a shell special built-in that continues " +"[+DESCRIPTION?\bcontinue\b is a shell special built-in that continues " "execution at the top of smallest enclosing enclosing \bfor\b, " "\bselect\b, \bwhile\b, or \buntil\b loop, if any; or the top of " "the \an\a-th enclosing loop if \an\a is specified.]" @@ -380,7 +358,7 @@ USAGE_LICENSE "each \aname\a that is specified, and \b=\b\avalue\a is not " "specified, the current value of the alias corresponding to " "\aname\a is written to standard output. If \b=\b\avalue\a is " - "specified, the alias \aname\a will be created or redefined.]" + "specified, the alias \aname\a will be created or redefined.]" "[+?\balias\b is built-in to the shell as a declaration command so that " "field splitting and pathname expansion are not performed on " "the arguments. Tilde expansion occurs on \avalue\a. An alias " @@ -468,7 +446,7 @@ USAGE_LICENSE "[+?In the first form with one operand, if \adirectory\a begins with " "\b/\b, or if the first component is \b.\b or \b..\b, the " "directory will be changed to this directory. If directory is \b-\b, " - "the directory will be changed to the last directory visited. " + "the directory will be changed to the last directory visited. " "Otherwise, if the \bCDPATH\b environment variable is set, \bcd\b " "searches for \adirectory\a relative to each directory named in " "the colon separated list of directories defined by \bCDPATH\b. " @@ -565,7 +543,7 @@ USAGE_LICENSE "the script completes execution.]" "[+?When \aname\a refers to a file, the \bPATH\b variable is searched " "for the file containing commands. In this case execute permission " - "is not required for \aname\a.]" + "is not required for \aname\a.]" "[+?If any \aarg\as are specified, these become the positional parameters " "for the duration of the function or script and are restored " "upon completion.]" @@ -663,7 +641,7 @@ USAGE_LICENSE "If \b=\b\avalue\a is specified, the variable \aname\a is " "set to \avalue\a.]" "[+?If no \aname\as are specified then the names and values of all " - "exported variables are written to standard output.]" + "exported variables are written to standard output.]" "[+?\bexport\b is built-in to the shell as a declaration command so that " "field splitting and pathname expansion are not performed on " "the arguments. Tilde expansion occurs on \avalue\a.]" @@ -780,10 +758,10 @@ USAGE_LICENSE "argument starts with - or +. The special attributes are currently " "informational with respect to \boptget\b(3), but may be useful to " "applications that parse \b--api\b output. The special attributes are:]{" - "[+listof?zero or more of the possible option values may be specified, " + "[+listof?zero or more of the possible option values may be specified, " "separated by \b,\b or space.]" - "[+oneof?exactly one of the possible option values must be specified]" - "[+ignorecase?case ignored in matching the long option name]" + "[+oneof?exactly one of the possible option values must be specified]" + "[+ignorecase?case ignored in matching the long option name]" "}" "[+4.?A option value description.]" "[+5.?A argument specification. A list of valid option argument values " @@ -865,7 +843,7 @@ _JOB_ "[+EXIT STATUS?]{" "[+0?If all background jobs are started.]" "[+>0?If one more jobs does not exist or there are no background " - "jobs.]" + "jobs.]" "}" "[+SEE ALSO?\bwait\b(1), \bfg\b(1), \bdisown\b(1), \bjobs\b(1)]" @@ -963,7 +941,7 @@ const char sh_opthash[] = "[+SEE ALSO?\bsh\b(1), \balias\b(1)]" ; -const char sh_opthist[] = +const char sh_opthist[] = "[-1cn?@(#)$Id: hist (AT&T Research/ksh93) 2020-07-16 $\n]" USAGE_LICENSE "[+NAME?fc, hist, history, r - process command history list]" @@ -1010,7 +988,7 @@ USAGE_LICENSE "command. A value of \b-\b for \aeditor\a is equivalent to " "specifying the \b-s\b option.]" "[l?List the commands rather than editing and reexecuting them.]" -"[N]#[num?Start at \anum\a commands back.]" +"[N]#[num?Start at \anum\a commands back.]" "[n?Suppress the command numbers when the commands are listed.]" #if SHOPT_HISTEXPAND "[p?Writes the result of history expansion for each operand to standard " @@ -1029,13 +1007,13 @@ USAGE_LICENSE "the command that gets reexecuted. Otherwise, it is one of the " "following:]{" "[+0?Successfully completion of the listing.]" - "[+>0?An error occurred.]" + "[+>0?An error occurred.]" "}" "[+SEE ALSO?\bksh\b(1), \bsh\b(1), \bed\b(1)]" ; -const char sh_optkill[] = +const char sh_optkill[] = "[-1c?\n@(#)$Id: kill (AT&T Research) 2012-04-13 $\n]" USAGE_LICENSE "[+NAME?kill - terminate or signal process]" @@ -1150,7 +1128,7 @@ const char sh_optprint[] = USAGE_LICENSE "[+NAME?print - write arguments to standard output]" "[+DESCRIPTION?By default, \bprint\b writes each \astring\a operand to " - "standard output and appends a newline character.]" + "standard output and appends a newline character.]" "[+?Unless, the \b-r\b or \b-f\b option is specified, each \b\\\b " "character in each \astring\a operand is processed specially as " "follows:]{" @@ -1173,7 +1151,7 @@ USAGE_LICENSE "operands than format specifiers, the format string is " "reprocessed from the beginning. If there are fewer \astring\a " "operands than format specifiers, then outputting will end " - "at the first unneeded format specifier.]" + "at the first unneeded format specifier.]" "[e?Unless \b-f\b is specified, process \b\\\b sequences in each \astring\a " "operand as described above. This is the default behavior.]" "[n?Do not append a new-line character to the output.]" @@ -1205,7 +1183,7 @@ const char sh_optprintf[] = USAGE_LICENSE "[+NAME?printf - write formatted output]" "[+DESCRIPTION?\bprintf\b writes each \astring\a operand to " - "standard output using \aformat\a to control the output format.]" + "standard output using \aformat\a to control the output format.]" "[+?The \aformat\a operands supports the full range of ANSI C formatting " "specifiers plus the following additional specifiers:]{" "[+%b?Each character in the \astring\a operand is processed " @@ -1463,7 +1441,7 @@ USAGE_LICENSE "value must be specified when creating each instance of the type " "and the value is readonly for each instance.]" "[+?If no \aname\as are specified then the names and values of all " - "readonly variables are written to standard output.]" + "readonly variables are written to standard output.]" "[+?\breadonly\b is built-in to the shell as a declaration command so that " "field splitting and pathname expansion are not performed on " "the arguments. Tilde expansion occurs on \avalue\a.]" @@ -1542,7 +1520,7 @@ USAGE_LICENSE "[+?The \b-s\b and \b-c\b options are mutually exclusive. If the \b-c\b " "option is specified, the first \aarg\a is the command-line string " "and must be specified. Any remaining \aarg\as will be used " - "to initialize \b$0\b and positional parameters.]" + "to initialize \b$0\b and positional parameters.]" "[+?If the neither \b-s\b nor \b-c\b is specified, then the first \barg\b " "will be the pathname of the file containing commands and \b$0\b " "will be set to this value. If there is no file with this pathname, " @@ -1590,9 +1568,6 @@ USAGE_LICENSE "[I:regress]:[intercept?Enable the regression test \aintercept\a. Must be " "the first command line option(s).]" #endif -#if SHOPT_BASH - "\fbash2\f" -#endif "\fabc\f" "?" "[T?Enable implementation specific test code defined by mask.]#[mask]" @@ -1663,7 +1638,7 @@ USAGE_LICENSE "positional parameters to the left by the number of places " "defined by \an\a, or \b1\b if \an\a is omitted. The number of " "positional parameters remaining will be reduced by the " - "number of places that are shifted.]" + "number of places that are shifted.]" "[+?If \an\a is given, it will be evaluated as an arithmetic expression " "to determinate the number of places to shift. It is an error " "to shift more than the number of positional parameters or a " @@ -1751,7 +1726,7 @@ USAGE_LICENSE "the shell does not know about causes \btrap\b to exit with a " "non-zero exit status, but does not terminate the invoking shell.]" "[+?If no \aaction\a or \acondition\as are specified then all the current " - "trap settings are written to standard output.]" + "trap settings are written to standard output.]" "[p?Causes the current traps to be output in a format that can be processed " "as input to the shell to recreate the current traps.]" "\n" @@ -1805,12 +1780,8 @@ USAGE_LICENSE "[+?\btypeset\b is built in to the shell as a declaration command so that " "field splitting and pathname expansion are not performed on " "the arguments. Tilde expansion occurs on \avalue\a.]" -#if 1 "[a]:?[type?Indexed array. This is the default. If \b[\b\atype\a\b]]\b is " "specified, each subscript is interpreted as a value of type \atype\a.]" -#else -"[a?Indexed array. this is the default.]" -#endif "[b?Each \aname\a may contain binary data. Its value is the mime " "base64 encoding of the data. It can be used with \b-Z\b, " "to specify fixed sized fields.]" @@ -2045,11 +2016,11 @@ USAGE_LICENSE "[+NAME?whence, type - locate a command and describe its type]" "[+DESCRIPTION?Without \b-v\b, \bwhence\b writes on standard output an " "absolute pathname, if any, corresponding to \aname\a based " - "on the complete search order that the shell uses. If \aname\a " + "on the complete search order that the shell uses. If \aname\a " "is not found, then no output is produced.]" "[+?If \b-v\b is specified, the output will also contain information " "that indicates how the given \aname\a would be interpreted by " - "the shell in the current execution environment.]" + "the shell in the current execution environment.]" "[+?The \btype\b command is equivalent to \bwhence -v\b.]" "[a?Like \b-v\b but displays all uses for each \aname\a rather than the first.]" "[f?Do not check for functions.]" diff --git a/cde/programs/dtksh/init.c b/cde/programs/dtksh/init.c index 0a5b848e..92978a3f 100644 --- a/cde/programs/dtksh/init.c +++ b/cde/programs/dtksh/init.c @@ -119,10 +119,6 @@ char e_version[] = "\n@(#)$Id: Version " #define ATTRS 1 "A" #endif -#if SHOPT_BASH -#define ATTRS 1 - "B" -#endif #if SHOPT_BGX #define ATTRS 1 "J" @@ -148,10 +144,6 @@ char e_version[] = "\n@(#)$Id: Version " #endif SH_RELEASE " $\0\n"; -#if SHOPT_BASH - extern void bash_init(Shell_t*,int); -#endif - #define RANDMASK 0x7fff #ifndef ARG_MAX @@ -239,7 +231,7 @@ typedef struct _init_ static Init_t *ip; static int lctype; static int nbltins; -static void env_init(Shell_t*); +static void env_init(Shell_t*,int); static Init_t *nv_init(Shell_t*); static Dt_t *inittree(Shell_t*,const struct shtable2*); static int shlvl; @@ -300,7 +292,7 @@ static void put_history(register Namval_t* np,const char *val,int flags,Namfun_t char *cp; if(val && histopen) { - if(np==HISTFILE && (cp=nv_getval(np)) && strcmp(val,cp)==0) + if(np==HISTFILE && (cp=nv_getval(np)) && strcmp(val,cp)==0) return; if(np==HISTSIZE && sh_arith(shp,val)==nv_getnum(HISTSIZE)) return; @@ -350,7 +342,7 @@ static void put_restricted(register Namval_t* np,const char *val,int flags,Namfu char *name = nv_name(np); if(!(flags&NV_RDONLY) && sh_isoption(SH_RESTRICTED)) errormsg(SH_DICT,ERROR_exit(1),e_restricted,nv_name(np)); - if(np==PATHNOD || (path_scoped=(strcmp(name,PATHNOD->nvname)==0))) + if(np==PATHNOD || (path_scoped=(strcmp(name,PATHNOD->nvname)==0))) { /* Clear the hash table */ nv_scan(shp->track_tree,nv_rehash,(void*)0,NV_TAGGED,NV_TAGGED); @@ -359,7 +351,7 @@ static void put_restricted(register Namval_t* np,const char *val,int flags,Namfu } if(val && !(flags&NV_RDONLY) && np->nvalue.cp && strcmp(val,np->nvalue.cp)==0) return; - if(np==FPATHNOD || (fpath_scoped=(strcmp(name,FPATHNOD->nvname)==0))) + if(np==FPATHNOD || (fpath_scoped=(strcmp(name,FPATHNOD->nvname)==0))) shp->pathlist = (void*)path_unsetfpath(shp); nv_putv(np, val, flags, fp); shp->universe = 0; @@ -380,10 +372,6 @@ static void put_restricted(register Namval_t* np,const char *val,int flags,Namfu if(mp && (val=nv_getval(mp))) nv_putval(mp,val,NV_RDONLY); } -#if 0 -sfprintf(sfstderr,"%d: name=%s val=%s\n",getpid(),name,val); -path_dump((Pathcomp_t*)shp->pathlist); -#endif } } @@ -401,7 +389,6 @@ static void put_cdpath(register Namval_t* np,const char *val,int flags,Namfun_t } #ifdef _hdr_locale - #ifdef BUILD_DTKSH /* * This version of putenv uses the hash storage to assign environment values @@ -910,23 +897,13 @@ static char *msg_translate(const char *message,int type) } #else - -#if ERROR_VERSION >= 20000101L static char* msg_translate(const char* catalog, const char* message) { NOT_USED(catalog); return((char*)message); } -#else - static char* msg_translate(const char* message, int type) - { - NOT_USED(type); - return((char*)message); - } #endif -#endif /* BUILD_DTKSH */ - /* Trap for LC_ALL, LC_CTYPE, LC_MESSAGES, LC_COLLATE and LANG */ static void put_lang(Namval_t* np,const char *val,int flags,Namfun_t *fp) { @@ -1019,10 +996,11 @@ static char *msg_translate(const char *message,int type) sh_lexstates[ST_BRACE]=(char*)sh_lexrstates[ST_BRACE]; } } -#if ERROR_VERSION < 20000101L || defined(BUILD_DTKSH) +#ifdef BUILD_DTKSH if(type==LC_ALL || type==LC_MESSAGES) error_info.translate = msg_translate; #endif + } #endif /* _hdr_locale */ @@ -1287,7 +1265,7 @@ static int hasgetdisc(register Namfun_t *fp) void sh_setmatch(Shell_t *shp,const char *v, int vsize, int nmatch, regoff_t match[],int index) { struct match *mp = &ip->SH_MATCH_init; - Namval_t *np = nv_namptr(mp->node,0); + Namval_t *np = nv_namptr(mp->node,0); register int i,n,x; unsigned int savesub = shp->subshell; Namarr_t *ap = nv_arrayptr(SH_MATCHNOD); @@ -1364,7 +1342,7 @@ void sh_setmatch(Shell_t *shp,const char *v, int vsize, int nmatch, regoff_t mat mp->match = (int*)malloc(i+vsize+1); mp->vsize = i+vsize+1; } - mp->val = ((char*)mp->match)+i; + mp->val = ((char*)mp->match)+i; memcpy(mp->match+index,match,nmatch*2*sizeof(match[0])); for(x=0,i=0; i < 2*nmatch; i++) { @@ -1381,7 +1359,7 @@ void sh_setmatch(Shell_t *shp,const char *v, int vsize, int nmatch, regoff_t mat mp->val[vsize] = 0; mp->lastsub[0] = mp->lastsub[1] = -1; } -} +} #define array_scan(np) ((nv_arrayptr(np)->nelem&ARRAY_SCAN)) @@ -1448,7 +1426,7 @@ static const Namdisc_t SH_VERSION_disc = { 0, 0, get_version, nget_version }; static const Namdisc_t IFS_disc = { sizeof(struct ifs), put_ifs, get_ifs }; const Namdisc_t RESTRICTED_disc = { sizeof(Namfun_t), put_restricted }; -static const Namdisc_t CDPATH_disc = { sizeof(Namfun_t), put_cdpath }; +static const Namdisc_t CDPATH_disc = { sizeof(Namfun_t), put_cdpath }; static const Namdisc_t EDITOR_disc = { sizeof(Namfun_t), put_ed }; static const Namdisc_t HISTFILE_disc = { sizeof(Namfun_t), put_history }; static const Namdisc_t OPTINDEX_disc = { sizeof(Namfun_t), put_optindex, 0, nget_optindex, 0, 0, clone_optindex }; @@ -1526,7 +1504,7 @@ static char* get_math(register Namval_t* np, Namfun_t *fp) } val = sfstruse(shp->strbuf); return(val); - + } static char *setdisc_any(Namval_t *np, const char *event, Namval_t *action, Namfun_t *fp) @@ -1631,7 +1609,7 @@ int sh_type(register const char *path) { register const char* s; register int t = 0; - + if (s = (const char*)strrchr(path, '/')) { if (*path == '-') @@ -1647,7 +1625,7 @@ int sh_type(register const char *path) } for (;;) { - if (!(t & (SH_TYPE_KSH|SH_TYPE_BASH))) + if (!(t & SH_TYPE_KSH)) { if (*s == 'k') { @@ -1655,14 +1633,6 @@ int sh_type(register const char *path) t |= SH_TYPE_KSH; continue; } -#if SHOPT_BASH - if (*s == 'b' && *(s+1) == 'a') - { - s += 2; - t |= SH_TYPE_BASH; - continue; - } -#endif } if (!(t & (SH_TYPE_PROFILE|SH_TYPE_RESTRICTED))) { @@ -1687,6 +1657,12 @@ int sh_type(register const char *path) { s++; t |= SH_TYPE_SH; +#if _WINIX + if (!(t & SH_TYPE_KSH) && (!*s || *s == '.')) +#else + if (!(t & SH_TYPE_KSH) && !*s) +#endif + t |= SH_TYPE_POSIX; if ((t & SH_TYPE_KSH) && *s == '9' && *(s+1) == '3') s += 2; #if _WINIX @@ -1696,7 +1672,7 @@ int sh_type(register const char *path) if (!isalnum(*s)) return t; } - return t & ~(SH_TYPE_BASH|SH_TYPE_KSH|SH_TYPE_PROFILE|SH_TYPE_RESTRICTED); + return t & ~(SH_TYPE_KSH|SH_TYPE_PROFILE|SH_TYPE_RESTRICTED); } @@ -1760,6 +1736,9 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) { beenhere = 1; shp = &sh; +#if SHOPT_REGRESS + sh_regress_init(shp); +#endif shgd = newof(0,struct shared,1,0); shgd->current_pid = shgd->pid = getpid(); shgd->ppid = getppid(); @@ -1794,9 +1773,7 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) shp->stk = stkstd; sfsetbuf(shp->strbuf,(char*)0,64); sh_onstate(SH_INIT); -#if ERROR_VERSION >= 20000102L error_info.catalog = e_dict; -#endif #if SHOPT_REGRESS { Opt_t* nopt; @@ -1805,7 +1782,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) char** av = argv; char* regress[3]; - sh_regress_init(shp); regress[0] = "__regress__"; regress[2] = 0; /* NOTE: only shp is used by __regress__ at this point */ @@ -1827,7 +1803,9 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) break; nopt = optctx(0, 0); oopt = optctx(nopt, 0); + error_info.exit = exit; /* avoid crash on b___regress__ error as shell is not fully initialized */ b___regress__(2, regress, &shp->bltindata); + error_info.exit = sh_exit; optctx(oopt, nopt); } } @@ -1849,14 +1827,17 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) stakinstall(NIL(Stak_t*),nospace); /* set up memory for name-value pairs */ shp->init_context = nv_init(shp); - /* read the environment */ + /* initialize shell type */ if(argc>0) { type = sh_type(*argv); if(type&SH_TYPE_LOGIN) shp->login_sh = 2; + if(type&SH_TYPE_POSIX) + sh_onoption(SH_POSIX); } - env_init(shp); + /* read the environment; don't import attributes yet */ + env_init(shp,0); if(!ENVNOD->nvalue.cp) { sfprintf(shp->strbuf,"%s/.kshrc",nv_getval(HOME)); @@ -1873,17 +1854,8 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) char *cp=nv_getval(L_ARGNOD); char buff[PATH_MAX+1]; shp->gd->shpath = 0; -#if _AST_VERSION >= 20090202L if((n = pathprog(NiL, buff, sizeof(buff))) > 0 && n <= sizeof(buff)) shp->gd->shpath = strdup(buff); -#else - sfprintf(shp->strbuf,"/proc/%d/exe",getpid()); - if((n=readlink(sfstruse(shp->strbuf),buff,sizeof(buff)-1))>0) - { - buff[n] = 0; - shp->gd->shpath = strdup(buff); - } -#endif else if((cp && (sh_type(cp)&SH_TYPE_SH)) || (argc>0 && strchr(cp= *argv,'/'))) { if(*cp=='/') @@ -1918,17 +1890,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) /* check for profile shell */ else if(type&SH_TYPE_PROFILE) sh_onoption(SH_PFSH); -#endif -#if SHOPT_BASH - /* check for invocation as bash */ - if(type&SH_TYPE_BASH) - { - shp>userinit = userinit = bash_init; - sh_onoption(SH_BASH); - sh_onstate(SH_PREINIT); - (*userinit)(shp, 0); - sh_offstate(SH_PREINIT); - } #endif /* look for options */ /* shp->st.dolc is $# */ @@ -1977,13 +1938,16 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) beenhere = 2; } } + /* import variable attributes from environment */ + if(!sh_isoption(SH_POSIX)) + env_init(shp,1); #if SHOPT_PFSH if (sh_isoption(SH_PFSH)) { struct passwd *pw = getpwuid(shp->gd->userid); if(pw) shp->gd->user = strdup(pw->pw_name); - + } #endif /* set[ug]id scripts require the -p flag */ @@ -2031,13 +1995,11 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) shp->bltindata.shtrap = sh_trap; shp->bltindata.shexit = sh_exit; shp->bltindata.shbltin = sh_addbuiltin; -#if _AST_VERSION >= 20080617L shp->bltindata.shgetenv = sh_getenv; shp->bltindata.shsetenv = sh_setenviron; astintercept(&shp->bltindata,1); -#endif #if 0 -#define NV_MKINTTYPE(x,y,z) nv_mkinttype(#x,sizeof(x),(x)-1<0,(y),(Namdisc_t*)z); +#define NV_MKINTTYPE(x,y,z) nv_mkinttype(#x,sizeof(x),(x)-1<0,(y),(Namdisc_t*)z); NV_MKINTTYPE(pid_t,"process id",0); NV_MKINTTYPE(gid_t,"group id",0); NV_MKINTTYPE(uid_t,"user id",0); @@ -2054,7 +2016,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) #endif if(shp->userinit=userinit) (*userinit)(shp, 0); - #ifdef BUILD_DTKSH int * lockedFds; @@ -2085,7 +2046,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) SyncEnv("NLSPATH"); SyncEnv("LANG"); #endif - return(shp); } @@ -2492,20 +2452,24 @@ static Dt_t *inittree(Shell_t *shp,const struct shtable2 *name_vals) /* * read in the process environment and set up name-value pairs * skip over items that are not name-value pairs + * + * Must be called with import_attributes == 0 first, then again with + * import_attributes == 1 if variable attributes are to be imported + * from the environment. */ -static void env_init(Shell_t *shp) +static void env_init(Shell_t *shp, int import_attributes) { register char *cp; register Namval_t *np,*mp; register char **ep=environ; - char *dp,*next=0; + char *dp; int nenv=0,k=0,size=0; Namval_t *np0; -#ifdef _ENV_H - shp->env = env_open(environ,3); - env_delete(shp->env,"_"); -#endif + static char *next=0; /* next variable whose attributes to import */ + + if(import_attributes) + goto import_attributes; if(!ep) goto skip; while(*ep++) @@ -2522,10 +2486,10 @@ static void env_init(Shell_t *shp) mp->nvenv = (char*)cp; dp[-1] = '='; } - else if(*cp=='A' && cp[1]=='_' && cp[2]=='_' && cp[3]=='z' && cp[4]==0) + else if(strcmp(cp,e_envmarker)==0) { dp[-1] = '='; - next = cp+4; + next = cp + strlen(e_envmarker); continue; } else @@ -2535,7 +2499,7 @@ static void env_init(Shell_t *shp) mp->nvname = cp; size += strlen(cp); } - nv_onattr(mp,NV_IMPORT); + nv_onattr(mp,NV_IMPORT); if(mp->nvfun || nv_isattr(mp,NV_INTEGER)) nv_putval(mp,dp,0); else @@ -2557,6 +2521,18 @@ static void env_init(Shell_t *shp) dp += size+1; dtinsert(shp->var_base,np++); } +skip: + if(nv_isnull(PWDNOD) || nv_isattr(PWDNOD,NV_TAGGED)) + { + nv_offattr(PWDNOD,NV_TAGGED); + path_pwd(shp,0); + } + if((cp = nv_getval(SHELLNOD)) && (sh_type(cp)&SH_TYPE_RESTRICTED)) + sh_onoption(SH_RESTRICTED); /* restricted shell */ + return; + + /* Import variable attributes from environment (from variable named by e_envmarker) */ +import_attributes: while(cp=next) { if(next = strchr(++cp,'=')) @@ -2598,17 +2574,6 @@ static void env_init(Shell_t *shp) else cp += 2; } -skip: -#ifdef _ENV_H - env_delete(shp->env,e_envmarker); -#endif - if(nv_isnull(PWDNOD) || nv_isattr(PWDNOD,NV_TAGGED)) - { - nv_offattr(PWDNOD,NV_TAGGED); - path_pwd(shp,0); - } - if((cp = nv_getval(SHELLNOD)) && (sh_type(cp)&SH_TYPE_RESTRICTED)) - sh_onoption(SH_RESTRICTED); /* restricted shell */ return; } @@ -2674,7 +2639,7 @@ static void put_trans(register Namval_t* np,const char *val,int flags,Namfun_t * if(mp->lctype!=lctype) { mp->lctype = lctype; - mp->trans = wctrans(mp->name); + mp->trans = wctrans(mp->name); } if(!mp->trans || (flags&NV_INTEGER)) goto skip; diff --git a/cde/programs/dtksh/ksh93 b/cde/programs/dtksh/ksh93 index 9ba2c2e0..092b90da 160000 --- a/cde/programs/dtksh/ksh93 +++ b/cde/programs/dtksh/ksh93 @@ -1 +1 @@ -Subproject commit 9ba2c2e0dfadd78b1688161e4c4feb072a6d3447 +Subproject commit 092b90da81f1ab1d45495052615fb4bf83a25d03 -- 2.17.1
gdberrors
Description: Binary data
valgrinderrors
Description: Binary data
_______________________________________________ cdesktopenv-devel mailing list cdesktopenv-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel