diff --git a/src/cmd/ksh93/README b/src/cmd/ksh93/README index 1d4dcf003..eb7bcdf79 100644 --- a/src/cmd/ksh93/README +++ b/src/cmd/ksh93/README @@ -124,8 +124,6 @@ The options have the following defaults and meanings: OPTIMIZE on Optimize loop invariants for with for and while loops. - PFSH off Compile with support for profile shell. (Solaris; obsolete) - P_SUID off If set, all real UIDs, greater than or equal to this value will require the -p flag to run SUID/SGID scripts. @@ -156,8 +154,6 @@ The options have the following defaults and meanings: exiting the shell when you don't enter a command. If non-zero, TMOUT can not be set larger than this value. - TYPEDEF on Enable typeset type definitions. - VSH on Compile with vi command line editing. The original vi line editor code was provided by Pat Sullivan at CB. diff --git a/src/cmd/ksh93/SHOPT.sh b/src/cmd/ksh93/SHOPT.sh index 68e35c654..1854aa806 100644 --- a/src/cmd/ksh93/SHOPT.sh +++ b/src/cmd/ksh93/SHOPT.sh @@ -30,7 +30,6 @@ SHOPT NAMESPACE=1 # allow namespaces SHOPT NOECHOE=0 # turn off 'echo -e' when SHOPT_ECHOPRINT is disabled SHOPT OLDTERMIO= # support both TCGETA and TCGETS SHOPT OPTIMIZE=1 # optimize loop invariants -SHOPT PFSH=0 # Solaris exec_attr(4) profile execution (obsolete) SHOPT P_SUID= # real UIDs that require -p for set[ug]id (do not set to 0 to turn off) SHOPT RAWONLY=1 # make viraw the only vi mode SHOPT REGRESS= # enable __regress__ builtin and instrumented intercepts for testing @@ -41,5 +40,4 @@ SHOPT SUID_EXEC=1 # allow (safe) SUID/SGID shell scripts SHOPT SYSRC= # attempt . /etc/ksh.kshrc if interactive SHOPT TEST_L= # add 'test -l' as an alias for 'test -L' SHOPT TIMEOUT= # number of seconds for shell timeout -SHOPT TYPEDEF=1 # enable typeset type definitions SHOPT VSH=1 # vi edit mode diff --git a/src/cmd/ksh93/bltins/alarm.c b/src/cmd/ksh93/bltins/alarm.c index 334a7d10e..0f8c8aa6b 100644 --- a/src/cmd/ksh93/bltins/alarm.c +++ b/src/cmd/ksh93/bltins/alarm.c @@ -153,10 +153,7 @@ void sh_timetraps(void) sh_fun(tp->action,tp->node,(char**)0); tp->flags &= ~L_FLAG; if(!tp->flags) - { nv_unset(tp->node); - nv_close(tp->node); - } } } if(!(sh.sigflag[SIGALRM]&SH_SIGALRM)) @@ -221,8 +218,6 @@ static void putval(Namval_t* np, const char* val, int flag, Namfun_t* fp) { tp = (struct tevent*)nv_stack(np, (Namfun_t*)0); sh.st.timetrap = time_delete(tp,sh.st.timetrap); - if(tp->action) - nv_close(tp->action); nv_unset(np); free((void*)fp); } diff --git a/src/cmd/ksh93/bltins/getopts.c b/src/cmd/ksh93/bltins/getopts.c index 84507ba2a..07f9a5a82 100644 --- a/src/cmd/ksh93/bltins/getopts.c +++ b/src/cmd/ksh93/bltins/getopts.c @@ -180,7 +180,6 @@ int b_getopts(int argc,char *argv[],Shbltin_t *context) sh.st.optindex = opt_info.index; sh.st.optchar = opt_info.offset; nv_putval(np, options, 0); - nv_close(np); np = nv_open(nv_name(OPTARGNOD),sh.var_tree,0); if(opt_info.num == LONG_MIN) nv_putval(np, opt_info.arg, NV_RDONLY); @@ -198,7 +197,6 @@ int b_getopts(int argc,char *argv[],Shbltin_t *context) } else nv_putval(np, opt_info.arg, NV_RDONLY); - nv_close(np); sh_popcontext(&buff); opt_info.disc = 0; return(r); diff --git a/src/cmd/ksh93/bltins/print.c b/src/cmd/ksh93/bltins/print.c index d23973b8b..94d0bed1b 100644 --- a/src/cmd/ksh93/bltins/print.c +++ b/src/cmd/ksh93/bltins/print.c @@ -809,7 +809,6 @@ static int extend(Sfio_t* sp, void* v, Sffmt_t* fe) int32_t sl = 1; value->ip = (int*)(((char*)np->nvalue.lp) + (*((char*)&sl) ? 0 : sizeof(int))); } - nv_close(np); break; } case 'q': diff --git a/src/cmd/ksh93/bltins/read.c b/src/cmd/ksh93/bltins/read.c index 39bfb5c62..73db877a5 100644 --- a/src/cmd/ksh93/bltins/read.c +++ b/src/cmd/ksh93/bltins/read.c @@ -803,7 +803,6 @@ int sh_readline(char **names, volatile int fd, int flags, ssize_t size, long tim { if(name) { - nv_close(np); np = nv_open(name,sh.var_tree,NV_NOASSIGN|NV_VARNAME); name = *++names; } @@ -829,7 +828,6 @@ done: sfset(iop,SF_WRITE,1); if(!was_share) sfset(iop,SF_SHARE,0); - nv_close(np); if((sh.fdstatus[fd]&IOTTY) && !keytrap) tty_cooked(fd); if(flags&S_FLAG) diff --git a/src/cmd/ksh93/bltins/typeset.c b/src/cmd/ksh93/bltins/typeset.c index aa1053abc..de6502b87 100644 --- a/src/cmd/ksh93/bltins/typeset.c +++ b/src/cmd/ksh93/bltins/typeset.c @@ -393,14 +393,12 @@ int b_typeset(int argc,register char *argv[],Shbltin_t *context) case 'r': flag |= NV_RDONLY; break; -#if SHOPT_TYPEDEF case 'S': sflag=1; break; case 'h': tdata.help = opt_info.arg; break; -#endif /* SHOPT_TYPEDEF */ case 's': if(!isfloat) { @@ -851,7 +849,6 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp if(flag&NV_MOVE) { nv_rename(np, flag); - nv_close(np); continue; } if(tp->tp && nv_type(np)!=tp->tp) @@ -960,7 +957,6 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp else nv_unref(np); } - nv_close(np); } } else @@ -1142,13 +1138,6 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context) errormsg(SH_DICT,ERROR_exit(1),e_restricted,argv[-opt_info.index]); UNREACHABLE(); } -#if SHOPT_PFSH - if(sh_isoption(SH_PFSH)) - { - errormsg(SH_DICT,ERROR_exit(1),e_pfsh,argv[-opt_info.index]); - UNREACHABLE(); - } -#endif if(sh.subshell && !sh.subshare) sh_subfork(); } @@ -1403,8 +1392,6 @@ static int unall(int argc, char **argv, register Dt_t *troot) sh_subfork(); /* avoid affecting the parent shell's alias table */ nv_delete(np,troot,nofree_attr); } - else - nv_close(np); } else if(troot==sh.alias_tree) @@ -1532,11 +1519,7 @@ static int print_namval(Sfio_t *file,register Namval_t *np,register int flag, st sfprintf(file,"[%s]\n", sh_fmtq(nv_refsub(np))); } else -#if SHOPT_TYPEDEF sfputr(file,nv_isvtree(np)?cp:sh_fmtq(cp),'\n'); -#else - sfputr(file,sh_fmtq(cp),'\n'); -#endif /* SHOPT_TYPEDEF */ } return(1); } @@ -1581,10 +1564,8 @@ static void print_scan(Sfio_t *file, int flag, Dt_t *root, int option,struct tda tp->scanmask = flag&~NV_NOSCOPE; tp->scanroot = root; tp->outfile = file; -#if SHOPT_TYPEDEF if(!tp->prefix && tp->tp) tp->prefix = nv_name(tp->tp); -#endif /* SHOPT_TYPEDEF */ if(flag&NV_INTEGER) tp->scanmask |= (NV_DOUBLE|NV_EXPNOTE); if(flag==NV_LTOU || flag==NV_UTOL) diff --git a/src/cmd/ksh93/data/builtins.c b/src/cmd/ksh93/data/builtins.c index 007d19951..2b6d313c5 100644 --- a/src/cmd/ksh93/data/builtins.c +++ b/src/cmd/ksh93/data/builtins.c @@ -1595,9 +1595,6 @@ const char sh_optksh[] = #endif "\b${ENV-$HOME/.kshrc}\b, if it exists, as a profile. " "On by default for interactive shells; use \b+E\b to disable.]" -#if SHOPT_PFSH -"[P?Invoke the shell as a profile shell. See \bpfexec\b(1).]" -#endif #if SHOPT_KIA "[R]:[file?Do not execute the script, but create a cross-reference database " "in \afile\a that can be used in a separate shell script browser. The " @@ -1885,8 +1882,6 @@ const char sh_opttypeset[] = "[X]#?[n:=2*sizeof(long long)?Floating point number represented in hexadecimal " "notation. \an\a specifies the number of significant figures when the " "value is expanded.]" - -#if SHOPT_TYPEDEF "[h]:[string?Used within a type definition to provide a help string " "for variable \aname\a. Otherwise, it is ignored.]" "[S?Used with a type definition to indicate that the variable is shared by " @@ -1894,7 +1889,6 @@ const char sh_opttypeset[] = "with the \bfunction\b reserved word, the specified variables " "will have function static scope. Otherwise, the variable is " "unset prior to processing the assignment list.]" -#endif "[T]:?[tname?\atname\a is the name of a type name given to each \aname\a.]" "[Z]#?[n?Zero fill. If \an\a is given it represents the field width.]" "\n" diff --git a/src/cmd/ksh93/data/lexstates.c b/src/cmd/ksh93/data/lexstates.c index e152ff269..d7591791c 100644 --- a/src/cmd/ksh93/data/lexstates.c +++ b/src/cmd/ksh93/data/lexstates.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-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 * @@ -242,11 +242,7 @@ static const char sh_lexstate6[256] = S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_SPC2, -#if SHOPT_TYPEDEF S_SPC1, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, -#else - S_SPC2, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, -#endif S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ERR, S_ERR, S_ERR, S_ERR, S_ALP, diff --git a/src/cmd/ksh93/data/msg.c b/src/cmd/ksh93/data/msg.c index 9c6bf731e..2be92a457 100644 --- a/src/cmd/ksh93/data/msg.c +++ b/src/cmd/ksh93/data/msg.c @@ -67,9 +67,6 @@ const char e_subst[] = "%s: bad substitution"; const char e_create[] = "%s: cannot create"; const char e_tmpcreate[] = "cannot create temporary file"; const char e_restricted[] = "%s: restricted"; -#if SHOPT_PFSH -const char e_pfsh[] = "%s: disabled in profile shell"; -#endif const char e_copexists[] = "coprocess is running; cannot create a new coprocess"; const char e_exists[] = "%s: file already exists"; const char e_pipe[] = "cannot create pipe"; diff --git a/src/cmd/ksh93/data/options.c b/src/cmd/ksh93/data/options.c index 2ad1c1cae..07499ff6b 100644 --- a/src/cmd/ksh93/data/options.c +++ b/src/cmd/ksh93/data/options.c @@ -72,9 +72,6 @@ const Shtable_t shtab_options[] = "pipefail", SH_PIPEFAIL, "posix", SH_POSIX, "privileged", SH_PRIVILEGED, -#if SHOPT_PFSH - "profile", SH_PFSH|SH_COMMANDLINE, -#endif "rc", SH_RC|SH_COMMANDLINE, "restricted", SH_RESTRICTED, "showme", SH_SHOWME, diff --git a/src/cmd/ksh93/features/options b/src/cmd/ksh93/features/options index 619697e0f..c90ab74c5 100644 --- a/src/cmd/ksh93/features/options +++ b/src/cmd/ksh93/features/options @@ -34,10 +34,6 @@ tst note{ SHOPT_* option probe }end cross{ *1*) option MULTIBYTE 0 ;; esac - # deprecated: Solaris disabled SHOPT_PFSH in its build - #test -x /bin/pfexec -o -x /usr/bin/pfexec - #option PFSH $? - # if external 'test' supports lowercase -l as equivalent to -L, enable # SHOPT_TEST_L so ksh supports it for compatibility with local scripts ln -s /dev/null "$EXECROOT/link$$" diff --git a/src/cmd/ksh93/include/defs.h b/src/cmd/ksh93/include/defs.h index fb19ca009..56c0be183 100644 --- a/src/cmd/ksh93/include/defs.h +++ b/src/cmd/ksh93/include/defs.h @@ -107,10 +107,6 @@ extern char* sh_setenviron(const char*); # define PIPE_BUF 512 #endif -#if SHOPT_PFSH && ( !_lib_getexecuser || !_lib_free_execattr ) -# undef SHOPT_PFSH -#endif - #define MATCH_MAX 64 #define SH_READEVAL 0x4000 /* for sh_eval */ diff --git a/src/cmd/ksh93/include/nval.h b/src/cmd/ksh93/include/nval.h index 0b0636888..d372980e2 100644 --- a/src/cmd/ksh93/include/nval.h +++ b/src/cmd/ksh93/include/nval.h @@ -207,6 +207,7 @@ struct Namval #define nv_onattr(n,f) ((n)->nvflag |= (f)) #define nv_offattr(n,f) ((n)->nvflag &= ~(f)) #define nv_isarray(np) (nv_isattr((np),NV_ARRAY)) +#define nv_close(np) /* no-op */ /* The following are operations for associative arrays */ #define NV_AINIT 1 /* initialize */ @@ -252,7 +253,6 @@ extern Namval_t *nv_opensub(Namval_t*); /* name-value pair function prototypes */ extern int nv_adddisc(Namval_t*, const char**, Namval_t**); extern int nv_clone(Namval_t*, Namval_t*, int); -extern void nv_close(Namval_t*); extern void *nv_context(Namval_t*); extern Namval_t *nv_create(const char*, Dt_t*, int,Namfun_t*); extern void nv_delete(Namval_t*, Dt_t*, int); diff --git a/src/cmd/ksh93/include/path.h b/src/cmd/ksh93/include/path.h index 945ae71ba..0867672ba 100644 --- a/src/cmd/ksh93/include/path.h +++ b/src/cmd/ksh93/include/path.h @@ -97,9 +97,6 @@ extern int path_complete(const char*, const char*,struct argnod**); #if SHOPT_BRACEPAT extern int path_generate(struct argnod*,struct argnod**); #endif /* SHOPT_BRACEPAT */ -#if SHOPT_PFSH - extern int path_xattr(const char*, char*); -#endif /* SHOPT_PFSH */ #if SHOPT_DYNAMIC /* builtin/plugin routines */ @@ -112,9 +109,6 @@ extern const char e_timeformat[]; extern const char e_badtformat[]; extern const char e_dot[]; extern const char e_funload[]; -#if SHOPT_PFSH -extern const char e_pfsh[]; -#endif extern const char e_pwd[]; extern const char e_logout[]; extern const char e_alphanum[]; diff --git a/src/cmd/ksh93/include/shell.h b/src/cmd/ksh93/include/shell.h index fde61894d..fc160981f 100644 --- a/src/cmd/ksh93/include/shell.h +++ b/src/cmd/ksh93/include/shell.h @@ -99,9 +99,6 @@ typedef union Shnode_u Shnode_t; #define SH_NOUNSET 9 #define SH_NOGLOB 10 #define SH_ALLEXPORT 11 -#if SHOPT_PFSH -#define SH_PFSH 12 -#endif #define SH_IGNOREEOF 13 #define SH_NOCLOBBER 14 #define SH_MARKDIRS 15 diff --git a/src/cmd/ksh93/nval.3 b/src/cmd/ksh93/nval.3 index 92fa37936..36ca006ed 100644 --- a/src/cmd/ksh93/nval.3 +++ b/src/cmd/ksh93/nval.3 @@ -26,7 +26,6 @@ Namdisc_t; Namval_t *nv_open(const char *\fIname\fP, Dt_t *\fIdict\fP, int \fIflags\fP); Namval_t *nv_create(const char *\fIname\fP, Dt_t *\fIdict\fP, int \fIflags\fP, Namfun_t *\fIfp\fP); Namval_t *nv_namptr(void *\fIptr\fP, int \fIindx\fP); -void nv_close(Namval_t *\fInp\fP); void nv_delete(Namval_t *\fInp\fP, Dt_t *\fIdict\fP, int \fInofree\fP); .ft R .fi @@ -196,11 +195,6 @@ The \f3nv_namptr\fP function can be used on the pointer returned by corresponding node. Each of these nodes must be given the \f3NV_MINIMAL\fP attributes. .PP -The \f3nv_close()\fP indicates that the pointer returned by -\f3nv_open()\fP or \f3nv_opensub()\fP will not be referenced again. If the -name-value pair is unset, and not referenced elsewhere, -the name-value pair may be freed. -.PP The \f3nv_delete()\fP function will remove the node \fInp\fP from the dictionary \fIdict\fP. Unless \fInofree\fP is non-zero, the node \fInp\fP will also be freed. @@ -613,8 +607,6 @@ returns \f3NULL\fP. The \f3nv_opensub()\fP function returns a pointer to the name-value pair corresponding to the current subscript in an associative array. -Note that the \f3nv_close()\fP function should be called -when the pointer is no longer needed. .PP The \f3nv_putsub()\fP function is used to set the subscript for the next reference to \f3np\fP. diff --git a/src/cmd/ksh93/sh.1 b/src/cmd/ksh93/sh.1 index 93ef1ad46..841c28a43 100644 --- a/src/cmd/ksh93/sh.1 +++ b/src/cmd/ksh93/sh.1 @@ -1697,8 +1697,8 @@ element stores the submatch. For .B // -the array is two dimensional with the first subscript indicating the -most recent match and subpattern match and the second script indicating +the array is two-dimensional, with the first subscript indicating the +most recent match and subpattern match, and the second subscript indicating which match with .B 0 representing the first match. @@ -2498,7 +2498,7 @@ that directory. If no file name is found that matches the pattern, then that component of the filename is left unchanged unless the pattern is prefixed with -.B \(ap(N)\fP +.BR \(ap(N)\fP , in which case it is removed as described below. The special traversal names .B . @@ -2525,8 +2525,7 @@ will be ignored unless the first character of the pattern corresponding to this component is the character .BR . itself. -Note, that for other -uses of pattern matching the +Note that, for uses of pattern matching other than pathname expansion, the .B / and .B . @@ -2541,7 +2540,7 @@ When used for filename expansion, if the .B globstar option is on, an isolated pattern of two adjacent -.BR * 's +.BR * s will match all files and zero or more directories and subdirectories. If followed by a @@ -2562,7 +2561,7 @@ If the first character following the opening is a .B ! or -.B ^ +.BR ^ , then any character not enclosed is matched. A .B \- @@ -2574,9 +2573,9 @@ Within and .BR \*(CK\^ , character classes can be specified with the syntax -\f3[:\fP\f2class\fP\f3:]\fP -where class is one of the following classes defined in the ANSI C standard: -(Note that \f3word\fP is equivalent to \f3alnum\fP plus the character \f3_\fP.) +\f3[:\fP\f2class\fP\f3:]\fP, +where \f2class\fP is one of the following classes defined in the ANSI C standard +(note that \f3word\fP is equivalent to \f3alnum\fP plus the character \f3_\fP): .br .B .if n alnum alpha blank cntrl digit graph lower print punct space upper word xdigit @@ -2599,6 +2598,7 @@ and matches the collating symbol \f2symbol\fP. .RE .PD +.PP A .I pattern-list is a list of one or more patterns separated from each other @@ -2630,7 +2630,7 @@ Matches \f2n\^\fP occurrences of the given patterns. \f3{\fP\f2m\^\fP\f3,\fP\f2n\^\fP\f3}\fP(\fP\f2pattern-list\^\fP\f3)\fP Matches from \f2m\^\fP to \f2n\^\fP occurrences of the given patterns. If \f2m\^\fP is omitted, \f30\fP will be used. If \f2n\^\fP -is omitted at least \f2m\^\fP occurrences will be matched. +is omitted, at least \f2m\^\fP occurrences will be matched. .TP \f3\&@\&(\fP\f2pattern-list\^\fP\f3)\fP Matches exactly one of the given patterns. @@ -2640,19 +2640,19 @@ Matches exactly one of the given patterns. Matches anything except one of the given patterns. .PD .RE -By default, each pattern, or subpattern will match the +By default, each pattern or subpattern will match the longest string possible consistent with generating the longest overall match. If more than one match is possible, the one starting closest to the beginning of the string will be chosen. However, for each of the above -compound patterns a \f3\-\fP can be inserted in front of the \f3(\fP +compound patterns, a \f3\-\fP can be inserted in front of the \f3(\fP to cause the shortest match to the specified \f2pattern-list\^\fP to be used. .PP When \f2pattern-list\^\fP is contained within parentheses, the backslash character \f3\e\fP is treated specially even when inside a character class. All ANSI C character escapes are -recognized and match the specified character. In addition +recognized and match the specified character. In addition, the following escape sequences are recognized: .PD 0 .RS @@ -2683,7 +2683,7 @@ is a subpattern that can be used to match nested character expressions. Each .I pattern-pair\^ -is a two character sequence which cannot contain +is a two-character sequence that cannot contain .B & or .BR | . @@ -2696,7 +2696,7 @@ represents the beginning and ending characters of a nested group that will be skipped over when counting starting and ending character matches. The behavior is unspecified when the first character of a .I pattern-pair\^ -is alphanumeric +is alphanumeric, except for the following: .PD 0 .RS @@ -2709,11 +2709,11 @@ finding a match. Causes the ending character to be interpreted as an escape character. .TP .B L -Causes the ending character to be interpreted as a quote character +Causes the ending character to be interpreted as a quote character, causing all characters to be ignored when looking for a match. .TP .B Q -Causes the ending character to be interpreted as a quote character +Causes the ending character to be interpreted as a quote character, causing all characters other than any escape character to be ignored when looking for a match. .PD @@ -2724,14 +2724,14 @@ matches characters starting at .B { until the matching .B } -is found not counting any +is found, not counting any .B { or .B } -that is inside a double quoted string or preceded by the escape character +that is inside a double-quoted string or preceded by the escape character .BR \e . Without the -.B {\^} +.BR {\^} , this pattern matches any C language string. .PP Each subpattern in a composite pattern is numbered, @@ -2739,10 +2739,10 @@ starting at 1, by the location of the \f3(\fP within the pattern. The sequence \f3\e\fP\f2n\^\fP, where \f2n\^\fP is a single digit and \f3\e\fP\f2n\^\fP comes after -the \f2n\fP-th. subpattern, +the \f2n\fPth subpattern, matches the same string as the subpattern itself. .PP -Finally a pattern can contain subpatterns of the form +Finally, a pattern can contain subpatterns of the form \f3\(ap(\fP\f2options\^\fP\f3:\fP\f2pattern-list\^\fP\f3)\fP, where either \f2options\^\fP or \f3:\fP\f2pattern-list\^\fP can be omitted. Unlike the other compound patterns, @@ -2750,7 +2750,7 @@ these subpatterns are not counted in the numbered subpatterns. \f3:\fP\f2pattern-list\^\fP must be omitted for options .BR F , .BR G , -.B N , +.BR N , and .B V below. @@ -2768,33 +2768,41 @@ Disable the following options. .B E The remainder of the pattern uses extended regular expression syntax like the -.IR egrep (1) +.B \-E +option of the +.IR grep (1) command. .TP .B F -The remainder of the pattern uses -.IR fgrep (1) -expression syntax. +The remainder of the pattern uses the fixed pattern syntax of the +.B \-F +option of the +.IR grep (1) +command. .TP .B G The remainder of the pattern uses basic regular expression syntax like the .IR grep (1) -command. +command without options. .TP .B K The remainder of the pattern uses shell pattern syntax. This is the default. .TP .B N -This is ignored. However, when it is the first letter and is +When it is the first letter and is used with pathname expansion, and no matches occur, -the file pattern expands to the empty string. +the file pattern expands to the empty string +instead of remaining unexpanded. +Otherwise, it is ignored. .TP .B X The remainder of the pattern uses augmented regular expression syntax like the -.IR xgrep (1) +.B \-X +option of the AT&T AST version of the +.IR grep (1) command. .TP .B P @@ -2815,12 +2823,12 @@ shell option. File the longest match (greedy). This is the default. .TP .B l -Left anchor the pattern. This is the default for +Left-anchor the pattern. This is the default for .B K style patterns. .TP .B r -Right anchor the pattern. This is the default for +Right-anchor the pattern. This is the default for .B K style patterns. .PD diff --git a/src/cmd/ksh93/sh/args.c b/src/cmd/ksh93/sh/args.c index 317537446..8fcb5c515 100644 --- a/src/cmd/ksh93/sh/args.c +++ b/src/cmd/ksh93/sh/args.c @@ -48,9 +48,6 @@ static char *null; /* The following order is determined by sh_optset */ static const char optksh[] = -#if SHOPT_PFSH - "P" -#endif "Dircabefhkmnpstuvx" #if SHOPT_BRACEPAT "B" @@ -62,9 +59,6 @@ static const char optksh[] = ; static const int flagval[] = { -#if SHOPT_PFSH - SH_PFSH, -#endif SH_DICTIONARY, SH_INTERACTIVE, SH_RESTRICTED, SH_CFLAG, SH_ALLEXPORT, SH_NOTIFY, SH_ERREXIT, SH_NOGLOB, SH_TRACKALL, SH_KEYWORD, SH_MONITOR, SH_NOEXEC, SH_PRIVILEGED, SH_SFLAG, SH_TFLAG, @@ -306,10 +300,7 @@ int sh_argopts(int argc,register char *argv[]) strsort(sh.st.dolv+1,sh.st.dolc,strcoll); } if(np) - { nv_setvec(np,0,argc,argv); - nv_close(np); - } else if(argc>0 || ((cp=argv[-1]) && strcmp(cp,"--")==0)) argset(ap,argv-1); } diff --git a/src/cmd/ksh93/sh/array.c b/src/cmd/ksh93/sh/array.c index 97f4d8e64..19b362bec 100644 --- a/src/cmd/ksh93/sh/array.c +++ b/src/cmd/ksh93/sh/array.c @@ -404,7 +404,9 @@ static Namval_t *array_find(Namval_t *np,Namarr_t *arp, int flag) return(np); } -#if SHOPT_TYPEDEF +/* + * for 'typeset -T' types + */ int nv_arraysettype(Namval_t *np, Namval_t *tp, const char *sub, int flags) { Namval_t *nq; @@ -431,7 +433,6 @@ int nv_arraysettype(Namval_t *np, Namval_t *tp, const char *sub, int flags) } return(0); } -#endif /* SHOPT_TYPEDEF */ static Namfun_t *array_clone(Namval_t *np, Namval_t *mp, int flags, Namfun_t *fp) @@ -622,10 +623,8 @@ static void array_putval(Namval_t *np, const char *string, int flags, Namfun_t * nv_putval(mp, string, flags); if(string) { -#if SHOPT_TYPEDEF if(ap->hdr.type && ap->hdr.type!=nv_type(mp)) nv_arraysettype(np,ap->hdr.type,nv_getsub(np),0); -#endif /* SHOPT_TYPEDEF */ continue; } ap->nelem |= scan; @@ -713,10 +712,8 @@ static void array_putval(Namval_t *np, const char *string, int flags, Namfun_t * else if(mp==np) aq->val[aq->cur].cp = 0; } -#if SHOPT_TYPEDEF if(string && ap->hdr.type && nv_isvtree(np)) nv_arraysettype(np,ap->hdr.type,nv_getsub(np),0); -#endif /* SHOPT_TYPEDEF */ } while(!string && nv_nextsub(np)); if(ap) diff --git a/src/cmd/ksh93/sh/fault.c b/src/cmd/ksh93/sh/fault.c index 56f7ede7b..f5c4ee4c2 100644 --- a/src/cmd/ksh93/sh/fault.c +++ b/src/cmd/ksh93/sh/fault.c @@ -587,9 +587,7 @@ void sh_exit(register int xno) sh.arithrecursion = 0; sh.intrace = 0; sh.prefix = 0; -#if SHOPT_TYPEDEF sh.mktype = 0; -#endif /* SHOPT_TYPEDEF */ if(job.in_critical) job_unlock(); if(pp->mode == SH_JMPSCRIPT && !pp->prev) diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index 3622bbd28..34fd7b5fa 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -131,10 +131,6 @@ char e_version[] = "\n@(#)$Id: Version " #define ATTRS 1 "M" #endif -#if SHOPT_PFSH && _hdr_exec_attr -#define ATTRS 1 - "P" -#endif #if SHOPT_REGRESS #define ATTRS 1 "R" @@ -1200,14 +1196,6 @@ int sh_type(register const char *path) } if (!(t & (SH_TYPE_PROFILE|SH_TYPE_RESTRICTED))) { -#if SHOPT_PFSH - if (*s == 'p' && *(s+1) == 'f') - { - s += 2; - t |= SH_TYPE_PROFILE; - continue; - } -#endif if (*s == 'r') { s++; @@ -1406,11 +1394,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) /* check for restricted shell */ if(type&SH_TYPE_RESTRICTED) sh_onoption(SH_RESTRICTED); -#if SHOPT_PFSH - /* check for profile shell */ - else if(type&SH_TYPE_PROFILE) - sh_onoption(SH_PFSH); -#endif /* look for options */ /* sh.st.dolc is $# */ if((sh.st.dolc = sh_argopts(-argc,argv)) < 0) @@ -1468,15 +1451,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) /* import variable attributes from environment */ if(!sh_isoption(SH_POSIX)) env_import_attributes(save_envmarker); -#if SHOPT_PFSH - if (sh_isoption(SH_PFSH)) - { - struct passwd *pw = getpwuid(sh.userid); - if(pw) - sh.user = sh_strdup(pw->pw_name); - - } -#endif /* set[ug]id scripts require the -p flag */ if(sh.userid!=sh.euserid || sh.groupid!=sh.egroupid) { @@ -2054,7 +2028,6 @@ static char *env_init(void) { nv_onattr(np,NV_IMPORT); np->nvenv = cp; - nv_close(np); } else /* swap with front */ { diff --git a/src/cmd/ksh93/sh/lex.c b/src/cmd/ksh93/sh/lex.c index ef10abdcb..036ef2415 100644 --- a/src/cmd/ksh93/sh/lex.c +++ b/src/cmd/ksh93/sh/lex.c @@ -870,9 +870,7 @@ int sh_lex(Lex_t* lp) poplevel(lp); } break; -#if SHOPT_TYPEDEF case '@': -#endif /* SHOPT_TYPEDEF */ case '!': if(n!=S_ALP) goto dolerr; diff --git a/src/cmd/ksh93/sh/macro.c b/src/cmd/ksh93/sh/macro.c index b27794d9b..1875bf5a2 100644 --- a/src/cmd/ksh93/sh/macro.c +++ b/src/cmd/ksh93/sh/macro.c @@ -91,7 +91,7 @@ typedef struct _mac_ #define M_NAMECOUNT 7 /* ${#var*} */ #define M_TYPE 8 /* ${@var} */ -static noreturn void mac_error(Namval_t*); +static noreturn void mac_error(void); static int substring(const char*, size_t, const char*, int[], int); static void copyto(Mac_t*, int, int); static void comsubst(Mac_t*, Shnode_t*, int); @@ -1128,13 +1128,11 @@ retry1: { if(c=='#') type = M_SIZE; -#if SHOPT_TYPEDEF else if(c=='@') { type = M_TYPE; goto retry1; } -#endif /* SHOPT_TYPEDEF */ else type = M_VNAME; mode = c; @@ -1439,7 +1437,6 @@ retry1: if(ap && !mp->dotdot && !(ap->nelem&ARRAY_UNDEF)) addsub = 1; } -#if SHOPT_TYPEDEF else if(type==M_TYPE) { Namval_t *nq = nv_type(np); @@ -1450,7 +1447,6 @@ retry1: nv_attribute(np,sh.strbuf,"typeset",1); v = sfstruse(sh.strbuf); } -#endif /* SHOPT_TYPEDEF */ #if SHOPT_FILESCAN else if(sh.cur_line && np==REPLYNOD) v = sh.cur_line; @@ -1521,7 +1517,7 @@ retry1: if(type>M_TREE) { if(c!=RBRACE) - mac_error(np); + mac_error(); if(type==M_NAMESCAN || type==M_NAMECOUNT) { sh.last_root = sh.var_tree; @@ -1602,7 +1598,7 @@ retry1: if(!isbracechar(c)) { if(!nulflg) - mac_error(np); + mac_error(); fcseek(-LEN); c = ':'; } @@ -1781,7 +1777,7 @@ retry1: vsize = v?strlen(v):0; } if(*ptr) - mac_error(np); + mac_error(); stkseek(stkp,offset); argp = 0; } @@ -2022,7 +2018,7 @@ retry2: goto retry2; } else - mac_error(np); + mac_error(); } } else if(var && sh_isoption(SH_NOUNSET) && type<=M_TREE && (!np || nv_isnull(np) || (nv_isarray(np) && !np->nvalue.cp))) @@ -2036,13 +2032,10 @@ retry2: } else id = nv_name(np); - nv_close(np); } errormsg(SH_DICT,ERROR_exit(1),e_notset,id); UNREACHABLE(); } - if(np) - nv_close(np); if(pattern) free(pattern); if(idx) @@ -2056,9 +2049,8 @@ nosub: return(1); } if(type) - mac_error(np); + mac_error(); fcseek(-1); - nv_close(np); return(0); } @@ -2798,10 +2790,8 @@ static char *special(register int c) /* * Handle macro expansion errors */ -static noreturn void mac_error(Namval_t *np) +static noreturn void mac_error(void) { - if(np) - nv_close(np); errormsg(SH_DICT,ERROR_exit(1),e_subst,fcfirst()); UNREACHABLE(); } diff --git a/src/cmd/ksh93/sh/name.c b/src/cmd/ksh93/sh/name.c index 3035a7432..5445605c4 100644 --- a/src/cmd/ksh93/sh/name.c +++ b/src/cmd/ksh93/sh/name.c @@ -77,16 +77,15 @@ struct adata char *attval; }; -#if SHOPT_TYPEDEF - struct sh_type - { +/* for a 'typeset -T' type */ +struct sh_type +{ void *previous; Namval_t **nodes; Namval_t *rp; short numnodes; short maxnodes; - }; -#endif /* SHOPT_TYPEDEF */ +}; #if NVCACHE struct Namcache @@ -175,7 +174,9 @@ void nv_outname(Sfio_t *out, char *name, int len) stakseek(offset); } -#if SHOPT_TYPEDEF +/* + * for 'typeset -T' types + */ Namval_t *nv_addnode(Namval_t* np, int remove) { register struct sh_type *sp = (struct sh_type*)sh.mktype; @@ -233,7 +234,6 @@ Namval_t *nv_addnode(Namval_t* np, int remove) sp->nodes[sp->numnodes++] = np; return(np); } -#endif /* SHOPT_TYPEDEF */ /* * given a list of assignments, determine is on the list @@ -271,8 +271,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) Namarr_t *ap; Namval_t node; struct Namref nr; -#if SHOPT_TYPEDEF - int maketype = flags&NV_TYPE; + int maketype = flags&NV_TYPE; /* make a 'typeset -T' type definition command */ struct sh_type shtp; if(maketype) { @@ -283,7 +282,6 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) shtp.rp = 0; shtp.nodes = (Namval_t**)sh_malloc(shtp.maxnodes*sizeof(Namval_t*)); } -#endif /* SHOPT_TYPEDEF */ #if SHOPT_NAMESPACE if(sh.namespace && nv_dict(sh.namespace)==sh.var_tree) flags |= NV_NOSCOPE; @@ -344,7 +342,6 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) stakputs(cp); cp = stakfreeze(1); } - nv_close(np); } } np = nv_open(cp,sh.var_tree,flag|NV_ASSIGN); @@ -378,11 +375,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) nv_settype(np,typ,0); } if((flags&NV_STATIC) && !nv_isattr(np,NV_EXPORT) && !nv_isnull(np)) -#if SHOPT_TYPEDEF goto check_type; -#else - continue; -#endif /* SHOPT_TYPEDEF */ ap=nv_arrayptr(np); #if SHOPT_FIXEDARRAY if(ap && ap->fixed) @@ -408,13 +401,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) } } if(array && tp->tre.tretyp!=TLST && !tp->com.comset && !tp->com.comarg) - { -#if SHOPT_TYPEDEF - goto check_type; -#else - continue; -#endif /* SHOPT_TYPEDEF */ - } + goto check_type; /* check for array assignment */ if(tp->tre.tretyp!=TLST && tp->com.comarg && !tp->com.comset && ((array&NV_IARRAY) || !((mp=tp->com.comnamp) && nv_isattr(mp,BLT_DCL)))) { @@ -422,14 +409,12 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) Dt_t *last_root = sh.last_root; char **argv = sh_argbuild(&argc,&tp->com,0); sh.last_root = last_root; -#if SHOPT_TYPEDEF if(sh.mktype && sh.dot_depth==0 && np==((struct sh_type*)sh.mktype)->nodes[0]) { sh.mktype = 0; errormsg(SH_DICT,ERROR_exit(1),"%s: not a known type name",argv[0]); UNREACHABLE(); } -#endif /* SHOPT_TYPEDEF */ if(!(arg->argflag&ARG_APPEND)) { #if SHOPT_FIXEDARRAY @@ -462,11 +447,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) sfwrite(sfstderr,")\n",2); } } -#if SHOPT_TYPEDEF goto check_type; -#else - continue; -#endif /* SHOPT_TYPEDEF */ } if((tp->tre.tretyp&COMMSK)==TFUN) goto skip; @@ -494,17 +475,11 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) sh.prefix = prefix; if(tp->com.comset->argval[1]!='[') nv_setvtree(np); - nv_close(np); -#if SHOPT_TYPEDEF goto check_type; -#else - continue; -#endif /* SHOPT_TYPEDEF */ } if(*cp!='.' && *cp!='[' && strchr(cp,'[')) { cp = stakcopy(nv_name(np)); - nv_close(np); if(!(arg->argflag&ARG_APPEND)) flag &= ~NV_ARRAY; sh.prefix_root = sh.first_root; @@ -570,9 +545,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) L_ARGNOD->nvfun = 0; } sh_exec(tp,sh_isstate(SH_ERREXIT)); -#if SHOPT_TYPEDEF if(sh.prefix) -#endif { L_ARGNOD->nvalue.nrp = node.nvalue.nrp; L_ARGNOD->nvflag = node.nvflag; @@ -594,11 +567,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) if(tp->com.comarg || tp->com.comset) np->nvfun->dsize = 0; } -#if SHOPT_TYPEDEF goto check_type; -#else - continue; -#endif /* SHOPT_TYPEDEF */ } cp = arg->argval; mp = 0; @@ -659,7 +628,6 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) sh_debug(trap,name,sub,av,append); } } -#if SHOPT_TYPEDEF check_type: if(maketype) { @@ -678,7 +646,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ) L_ARGNOD->nvfun = node.nvfun; } } -#endif /* SHOPT_TYPEDEF */ + /* continue loop */ } } @@ -1490,10 +1458,8 @@ nocache: } c = *cp; skip: -#if SHOPT_TYPEDEF if(np && sh.mktype) np = nv_addnode(np,0); -#endif /* SHOPT_TYPEDEF */ if(c=='=' && np && (flags&NV_ASSIGN)) { cp++; @@ -2271,10 +2237,8 @@ static int scanfilter(Namval_t *np, struct scan *sp) register int k=np->nvflag; register struct adata *tp = (struct adata*)sp->scandata; char *cp; -#if SHOPT_TYPEDEF if(!is_abuiltin(np) && tp && tp->tp && nv_type(np)!=tp->tp) return(0); -#endif /* SHOPT_TYPEDEF */ if(sp->scanmask==NV_TABLE && nv_isvtree(np)) k = NV_TABLE; if(sp->scanmask?(k&sp->scanmask)==sp->scanflags:(!sp->scanflags || (k&sp->scanflags))) @@ -2423,15 +2387,6 @@ void sh_envnolocal (register Namval_t *np, void *data) nv_onattr(np,NV_EXPORT); } -/* - * Currently this is a dummy, but someday will be needed - * for reference counting - */ -void nv_close(Namval_t *np) -{ - NOT_USED(np); -} - static void table_unset(register Dt_t *root, int flags, Dt_t *oroot) { register Namval_t *np,*nq, *npnext; @@ -3030,7 +2985,7 @@ void nv_newattr (register Namval_t *np, unsigned newatts, int size) np->nvflag |= newatts; goto skip; } -#endif /* SHOPT_TYPEDEF */ +#endif /* SHOPT_FIXEDARRAY */ } do { @@ -3113,7 +3068,7 @@ void nv_newattr (register Namval_t *np, unsigned newatts, int size) while(ap && nv_nextsub(np)); #if SHOPT_FIXEDARRAY skip: -#endif /* SHOPT_TYPEDEF */ +#endif /* SHOPT_FIXEDARRAY */ if(fp) np->nvfun = fp; if(ap) diff --git a/src/cmd/ksh93/sh/nvdisc.c b/src/cmd/ksh93/sh/nvdisc.c index b05bab4a2..189dd6db2 100644 --- a/src/cmd/ksh93/sh/nvdisc.c +++ b/src/cmd/ksh93/sh/nvdisc.c @@ -246,8 +246,7 @@ static void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle) struct blocked block, *bp = block_info(np, &block); Namval_t node; union Value *up = np->nvalue.up; -#if SHOPT_TYPEDEF - Namval_t *tp, *nr; + Namval_t *tp, *nr; /* for 'typeset -T' types */ if(val && (tp=nv_type(np)) && (nr=nv_open(val,sh.var_tree,NV_VARNAME|NV_ARRAY|NV_NOADD|NV_NOFAIL)) && tp==nv_type(nr)) { char *sub = nv_getsub(np); @@ -261,7 +260,6 @@ static void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle) nv_clone(nr,np,0); goto done; } -#endif /* SHOPT_TYPEDEF */ if(val || isblocked(bp,type)) { if(!nq || isblocked(bp,type)) @@ -1278,7 +1276,6 @@ Namval_t *sh_addbuiltin(const char *path, Shbltin_f bltin, void *extra) if(nq) { cp=nv_setdisc(nq,cp+1,np,(Namfun_t*)nq); - nv_close(nq); if(!cp) { errormsg(SH_DICT,ERROR_exit(1),e_baddisc,name); diff --git a/src/cmd/ksh93/sh/nvtree.c b/src/cmd/ksh93/sh/nvtree.c index 449f92c9f..c2d653491 100644 --- a/src/cmd/ksh93/sh/nvtree.c +++ b/src/cmd/ksh93/sh/nvtree.c @@ -878,7 +878,6 @@ static char **genvalue(char **argv, const char *prefix, int n, struct Walk *wp) if(wp->indent>0) sfnputc(outfile,'\t',wp->indent); nv_attribute(np,outfile,"typeset",1); - nv_close(np); sfputr(outfile,arg+m+r+(n?n:0),(k?'=':'\n')); if(!k) { diff --git a/src/cmd/ksh93/sh/nvtype.c b/src/cmd/ksh93/sh/nvtype.c index b8c6aaece..d1056cb35 100644 --- a/src/cmd/ksh93/sh/nvtype.c +++ b/src/cmd/ksh93/sh/nvtype.c @@ -450,10 +450,8 @@ static Namfun_t *clone_type(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp) } else nv_putval(nq,nv_getval(nr),NV_RDONLY); -#if SHOPT_TYPEDEF if(sh.mktype) nv_addnode(nr,1); -#endif /* SHOPT_TYPEDEF */ if(pp->strsize<0) continue; _nv_unset(nr,0); @@ -1303,7 +1301,6 @@ int nv_settype(Namval_t* np, Namval_t *tp, int flags) Namarr_t *ap=0; int nelem = 0; unsigned int subshell = sh.subshell; -#if SHOPT_TYPEDEF Namval_t *tq; if(nv_type(np)==tp) return(0); @@ -1341,8 +1338,8 @@ int nv_settype(Namval_t* np, Namval_t *tp, int flags) } } else -#endif /* SHOPT_TYPEDEF */ { + /* non-typeset -T type */ if(isnull) flags &= ~NV_APPEND; else if(!nv_isvtree(np)) diff --git a/src/cmd/ksh93/sh/path.c b/src/cmd/ksh93/sh/path.c index 945f34a84..72be8c08c 100644 --- a/src/cmd/ksh93/sh/path.c +++ b/src/cmd/ksh93/sh/path.c @@ -36,16 +36,6 @@ #include "test.h" #include "FEATURE/dynamic" #include "FEATURE/externs" -#if SHOPT_PFSH -# ifdef _hdr_exec_attr -# include -# endif -# if _lib_vfork -# include -# else -# define vfork() fork() -# endif -#endif #define RW_ALL (S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH) #define LIBCMD "cmd" @@ -87,60 +77,6 @@ static int ondefpath(const char *name) return(0); } -#if SHOPT_PFSH -int path_xattr(const char *path, char *rpath) -{ - char resolvedpath[PATH_MAX + 1]; - if (sh.user && *sh.user) - { - execattr_t *pf; - if(!rpath) - rpath = resolvedpath; - if (!realpath(path, resolvedpath)) - return -1; - if(pf=getexecuser(sh.user, KV_COMMAND, resolvedpath, GET_ONE)) - { - if (!pf->attr || pf->attr->length == 0) - { - free_execattr(pf); - return(0); - } - free_execattr(pf); - return(1); - } - } - errno = ENOENT; - return(-1); -} - -static pid_t pf_execve(const char *path, char *argv[],char *const envp[],int spawn) -{ - char resolvedpath[PATH_MAX + 1]; - pid_t pid; - if(spawn) - { - while((pid = vfork()) < 0) - _sh_fork(pid, 0, (int*)0); - if(pid) - return(pid); - } - if(!sh_isoption(SH_PFSH)) - return(execve(path, argv, envp)); - /* Solaris implements realpath(3C) using the resolvepath(2) */ - /* system call so we can save us to call access(2) first */ - - /* we can exec the command directly instead of via pfexec(1) if */ - /* there is a matching entry without attributes in exec_attr(4) */ - if(!path_xattr(path,resolvedpath)) - return(execve(path, argv, envp)); - --argv; - argv[0] = argv[1]; - argv[1] = resolvedpath; - return(execve("/usr/bin/pfexec", argv, envp)); -} -#endif /* SHOPT_PFSH */ - - static pid_t _spawnveg(const char *path, char* const argv[], char* const envp[], pid_t pgid) { pid_t pid; @@ -219,11 +155,7 @@ static pid_t command_xargs(const char *path, char *argv[],char *const envp[], in saveargs = 0; } } -#if SHOPT_PFSH - else if(spawn && !sh_isoption(SH_PFSH)) -#else else if(spawn) -#endif { sh.xargexit = exitval; if(saveargs) @@ -234,11 +166,7 @@ static pid_t command_xargs(const char *path, char *argv[],char *const envp[], in { if(saveargs) free((void*)saveargs); -#if SHOPT_PFSH - return(pf_execve(path,argv,envp,spawn)); -#else return(execve(path,argv,envp)); -#endif } } if(!spawn) @@ -1242,17 +1170,10 @@ pid_t path_spawn(const char *opath,register char **argv, char **envp, Pathcomp_t } else #endif -#if SHOPT_PFSH - if(spawn && !sh_isoption(SH_PFSH)) - pid = _spawnveg(opath, &argv[0], envp, spawn>>1); - else - pid = pf_execve(opath, &argv[0], envp, spawn); -#else if(spawn) pid = _spawnveg(opath, &argv[0], envp, spawn>>1); else pid = execve(opath, &argv[0], envp); -#endif /* SHOPT_PFSH */ if(xp) *xp = xval; #ifdef SHELLMAGIC @@ -1365,7 +1286,7 @@ static noreturn void exscript(register char *path,register char *argv[],char **e sh_close(sh.infd); sh_setstate(sh_state(SH_FORKED)); sfsync(sfstderr); -#if SHOPT_SUID_EXEC && !SHOPT_PFSH +#if SHOPT_SUID_EXEC /* check if file cannot open for read or script is setuid/setgid */ { static char name[] = "/tmp/euidXXXXXXXXXX"; @@ -1401,11 +1322,7 @@ static noreturn void exscript(register char *path,register char *argv[],char **e } savet = *--argv; *argv = path; -#if SHOPT_PFSH - pf_execve(e_suidexec,argv,envp,0); -#else execve(e_suidexec,argv,envp); -#endif fail: /* * The following code is just for compatibility diff --git a/src/cmd/ksh93/sh/tdump.c b/src/cmd/ksh93/sh/tdump.c index 830e3f33a..5b65a1b97 100644 --- a/src/cmd/ksh93/sh/tdump.c +++ b/src/cmd/ksh93/sh/tdump.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-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 * diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index 287e5da61..7c6727de1 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -60,7 +60,6 @@ #endif #define SH_NTFORK SH_TIMING -#define NV_BLTPFSH NV_ARRAY #if _lib_nice extern int nice(int); @@ -1026,19 +1025,6 @@ int sh_exec(register const Shnode_t *t, int flags) #endif /* SHOPT_NAMESPACE */ np = dtsearch(sh.fun_tree,np); } -#if SHOPT_PFSH - if(sh_isoption(SH_PFSH) && nv_isattr(np,NV_BLTINOPT) && !nv_isattr(np,NV_BLTPFSH)) - { - if(path_xattr(np->nvname,(char*)0)) - { - dtdelete(sh.bltin_tree,np); - np = 0; - } - else - nv_onattr(np,NV_BLTPFSH); - - } -#endif /* SHOPT_PFSH */ } if(com0) { @@ -1084,12 +1070,11 @@ int sh_exec(register const Shnode_t *t, int flags) flgs |= NV_MOVE; if(np==SYSNAMEREF || checkopt(com,'n')) flgs |= NV_NOREF; -#if SHOPT_TYPEDEF else if(argn>=3 && checkopt(com,'T')) { if(sh.subshell && !sh.subshare) sh_subfork(); -# if SHOPT_NAMESPACE +#if SHOPT_NAMESPACE if(sh.namespace) { if(!sh.strbuf2) @@ -1099,12 +1084,11 @@ int sh_exec(register const Shnode_t *t, int flags) nv_open(sh.prefix,sh.var_base,NV_VARNAME); } else -# endif /* SHOPT_NAMESPACE */ +#endif /* SHOPT_NAMESPACE */ sh.prefix = NV_CLASS; flgs |= NV_TYPE; } -#endif /* SHOPT_TYPEDEF */ if(sh.fn_depth && !sh.prefix) flgs |= NV_NOSCOPE; } @@ -2067,7 +2051,7 @@ int sh_exec(register const Shnode_t *t, int flags) case TLST: { - /* a list of commands are executed here */ + /* a list of commands is executed here */ do { sh_exec(t->lst.lstlef,errorflg|OPTIMIZE); @@ -2215,7 +2199,6 @@ int sh_exec(register const Shnode_t *t, int flags) sh.st.execbrk = (--sh.st.breakcnt !=0); sh.st.loopcnt--; sh_argfree(argsav,0); - nv_close(np); break; } @@ -2453,10 +2436,7 @@ int sh_exec(register const Shnode_t *t, int flags) { Namval_t *np = nv_open("TIMEFORMAT",sh.var_tree,NV_NOADD); if(np) - { format = nv_getval(np); - nv_close(np); - } if(!format) format = e_timeformat; } diff --git a/src/cmd/ksh93/tests/arrays2.sh b/src/cmd/ksh93/tests/arrays2.sh index da6290909..992056c6a 100755 --- a/src/cmd/ksh93/tests/arrays2.sh +++ b/src/cmd/ksh93/tests/arrays2.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-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 # diff --git a/src/cmd/ksh93/tests/basic.sh b/src/cmd/ksh93/tests/basic.sh index cb0ba0c22..14c6cf8a7 100755 --- a/src/cmd/ksh93/tests/basic.sh +++ b/src/cmd/ksh93/tests/basic.sh @@ -678,6 +678,16 @@ got=$(eval 'x=${ for i in test; do case $i in test) true;; esac; done; }' 2>&1) got=$(eval 'x=`for i in test; do case $i in test) true;; esac; done`' 2>&1) \ || err_exit "case in a for loop inside a \`comsub\` caused syntax error (got $(printf %q "$got"))" +# another obscure thing that got fixed as a side effect: literal here- +# document terminator '$( a b )' (no, it's not a command substitution) +exp=$'ok\nend' +saveLINENO=$LINENO +got=$(set +x; eval $'cat <<$( a b )\nok\n$( a b )\necho end' 2>&1) +((LINENO == saveLINENO + 2)) || err_exit "LINENO just got reset (expected $((saveLINENO + 2)), got $LINENO)" +LINENO=saveLINENO+3 +[[ $got == "$exp" ]] || err_exit 'pathological here-document terminator $( a b ) fails' \ + "(expected $(printf %q "$exp"), got $(printf %q "$got"))" + # ====== # Various DEBUG trap fixes: https://github.com/ksh93/ksh/issues/155 # https://github.com/ksh93/ksh/issues/187 diff --git a/src/cmd/ksh93/tests/comvar.sh b/src/cmd/ksh93/tests/comvar.sh index f25a351bb..c2128ec4a 100755 --- a/src/cmd/ksh93/tests/comvar.sh +++ b/src/cmd/ksh93/tests/comvar.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-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 # diff --git a/src/cmd/ksh93/tests/enum.sh b/src/cmd/ksh93/tests/enum.sh index bcc7eeb7a..f7b749e24 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-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 # diff --git a/src/cmd/ksh93/tests/nameref.sh b/src/cmd/ksh93/tests/nameref.sh index 72e0827eb..b31a4fdf7 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-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 # diff --git a/src/cmd/ksh93/tests/quoting2.sh b/src/cmd/ksh93/tests/quoting2.sh index d9f8382e8..81eca34fe 100755 --- a/src/cmd/ksh93/tests/quoting2.sh +++ b/src/cmd/ksh93/tests/quoting2.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-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 # @@ -278,6 +278,17 @@ exp='' got=$(unset var; set +x; eval 'echo ${var+'\''{}'\''}' 2>&1) [[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (6)" \ "(expected $(printf %q "$exp"), got $(printf %q "$got"))" +# https://github.com/ksh93/ksh/commit/5ed4c71 +unset var +exp='text between expansions' +got="${var:+'}text between expansions${var:+'}" +[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (7)" \ + "(expected $(printf %q "$exp"), got $(printf %q "$got"))" +var=foo +exp=\''text between expansions'\' +got="${var:+'}text between expansions${var:+'}" +[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (8)" \ + "(expected $(printf %q "$exp"), got $(printf %q "$got"))" # ====== exit $((Errors<125?Errors:125)) diff --git a/src/lib/libast/misc/glob.c b/src/lib/libast/misc/glob.c index b1abf02b5..0448f9530 100644 --- a/src/lib/libast/misc/glob.c +++ b/src/lib/libast/misc/glob.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-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 * @@ -544,7 +544,7 @@ skip: { /* * For security and usability, only match '..' or '.' as the final element if: - * - its' specified literally, or + * - it's specified literally, or * - we're in file name completion mode. * To avoid breaking globstar, make sure that '.' or '..' is skipped if, and only if, it is the * final element in the pattern (i.e., if 'pat' does not contain a slash) and is not specified