diff --git a/ANNOUNCE b/ANNOUNCE index 332b8ad4e..1eda087fe 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -190,6 +190,12 @@ New shell language features: command, which never worked and crashed the shell. See the manual for details on the new method. +- A new ${.sh.pid} variable has been added with similar functionality to + Bash's $BASHPID variable. It is set to the current shell's PID, unlike + $$ (which is set to the main shell's PID). In virtual subshells + ${.sh.pid} is not changed from its previous value, while in forked + subshells ${.sh.pid} is set to the subshell's process ID. + New features in built-in commands: - Usage error messages now show the --help/--man self-documentation options. diff --git a/src/cmd/INIT/RELEASE b/src/cmd/INIT/RELEASE index 677586b25..0d66b6b3e 100644 --- a/src/cmd/INIT/RELEASE +++ b/src/cmd/INIT/RELEASE @@ -528,7 +528,7 @@ 02-10-18 probe.win32: update for mingw make.probe: add bash workaround to SHELLMAGIC test package.sh: work around yet another Cygwin hassle -02-10-17 iffe.sh: short circuit id check for *[-+/\\]* +02-10-17 iffe.sh: short circuit ID check for *[-+/\\]* 02-10-08 regress.sh: unset FIGNORE to avoid rm . errors package.sh: unset FIGNORE to avoid rm . errors package.sh: $CC must at least compile and executable hello world @@ -580,7 +580,7 @@ 02-03-24 mamake.c: all shell actions wrapped with -c to avoid #! problems 02-03-23 package.sh: recover $PACKAGEROOT/bin/package if not in INIT package package.sh: precheck $CC, not `cc' - package.sh: fix install to use pax -ps to preserve set-uid/gid + package.sh: fix install to use pax -ps to preserve setuid/setgid package.sh: fix install to use list.installed for existing files only 02-03-17 package.sh: fix PAX initialization that was sometimes omitted for read package.sh: fix update delta sync fetch @@ -906,7 +906,7 @@ 96-10-11 iffe: *.iffe and *.iff for iffe src files hostinfo: tighten sgi.mips CPU type check 96-10-01 C.probe: add probe_libdir to catch alpha /usr/shlib -96-09-17 iffe: fix typ bug that failed for single id types! +96-09-17 iffe: fix typ bug that failed for single ID types! 96-08-31 hostinfo: handle recent SGI hinv CPU changes 96-07-17 make sure sizeof(long xxx)>sizeof(xxx) for typ long.xxx 96-05-09 C.probe: drop multiple / in stdinclude diff --git a/src/cmd/INIT/mktest.sh b/src/cmd/INIT/mktest.sh index cc237b7ee..a6aa93d14 100755 --- a/src/cmd/INIT/mktest.sh +++ b/src/cmd/INIT/mktest.sh @@ -43,7 +43,7 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in template commands in the \aunit\a.\brt\b file. The generated test script writes temporary output to '$PREFIX$'\aunit\a.tmp and compares it to the expected output in '$PREFIX$'\aunit\a.out. Run the test - script with the \b--accept\b option to (re)generate the + script with the \b--accept\b option to (re)generate '$PREFIX$'\aunit\a.out.] [s:style?The script style:]:[style:='$STYLE$'] { diff --git a/src/cmd/INIT/regress.sh b/src/cmd/INIT/regress.sh index a53ab61ff..ffc51220a 100644 --- a/src/cmd/INIT/regress.sh +++ b/src/cmd/INIT/regress.sh @@ -128,7 +128,7 @@ unit [ command [ arg ... ] ] the files.] [+INFO \b\adescription\a?\adescription\a is printed on the standard error.] - [+INITIALIZE?Called by \bregress\b to initialize a each + [+INITIALIZE?Called by \bregress\b to initialize each \bTEST\b group.] [+INPUT \b[ \b-e\b \afilter\a ]] [ \b-n\b ]] \afile\a | - \adata\a ...?The standard input is set to either the contents of \afile\a diff --git a/src/cmd/ksh93/README b/src/cmd/ksh93/README index f3c9b9247..3eed19540 100644 --- a/src/cmd/ksh93/README +++ b/src/cmd/ksh93/README @@ -36,7 +36,7 @@ The options have the following defaults and meanings: background job will block until a running background job completes. (2) SIGCHLD traps are queued so that each completing background job gets its own trap; $! is set to - the job pid and $? is set to the job exit status at the + the job PID and $? is set to the job exit status at the beginning of the trap. BRACEPAT on Brace expansion. Expands abc{d,e}f to abcdf abcef. @@ -120,8 +120,8 @@ The options have the following defaults and meanings: 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. + 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. RAWONLY on Turn on if the vi line mode doesn't work right unless you do a set -o viraw. @@ -208,7 +208,7 @@ permission, the SUID_EXEC compile option must be on, and ksh must be installed in the /bin directory, the /usr/bin directory, the /usr/lbin directory, or the /usr/local/bin directory and the name must end in sh. The program suid_exec must be installed in the /etc directory, must be owned by root, -and must be a suid program. If you must install ksh in some other directory +and must be an SUID program. If you must install ksh in some other directory and want to be able to run setuid/setgid and execute only scripts, then you will have to change the source code file sh/suid_exec.c explicitly. If you do not have ksh in one of these secure locations, /bin/sh will @@ -251,6 +251,7 @@ failures (crashes, and/or important functionality does not work). * AIX 7.1 on RISC (PowerPC) * DragonFly BSD 5.8 on x86_64 FreeBSD 12.2 on x86_64 + FreeBSD 13.0 on x86_64 FreeBSD 12.2 on arm64 (thanks to hyenias for donating access to a Pi) GNU/Linux: Alpine 3.12.3 (musl C library) on x86_64 GNU/Linux: CentOS 8.2 on x86_64 @@ -270,6 +271,7 @@ failures (crashes, and/or important functionality does not work). * NetBSD 8.1 on x86_64 * NetBSD 9.2 on x86_64 * OpenBSD 6.8 on x86_64 + OpenBSD 7.0 on x86_64 ** QNX 6.5.0 on i386 * Solaris 11.4 (gcc) on x86_64 Solaris 11.4 (Solaris Studio 12.5 cc) on x86_64 @@ -277,6 +279,7 @@ failures (crashes, and/or important functionality does not work). *** Windows 7 using Cygwin on x86 *** Windows 10 using Cygwin on x86_64 *** Windows 11 using Cygwin on x86_64 +* Windows 11 using WSL 2 with Ubuntu 20.04 on x86_64 *** Haiku R1/beta3 on x86_64 #### REPORTING BUGS #### diff --git a/src/cmd/ksh93/RELEASE b/src/cmd/ksh93/RELEASE index a5aa4944c..3a624d5e4 100644 --- a/src/cmd/ksh93/RELEASE +++ b/src/cmd/ksh93/RELEASE @@ -261,7 +261,7 @@ ____ 12-01-21 A bug in which typeset -L and typeset -R did not handle multibyte characters correctly has been fixed. 12-01-20 A bug that could cause the shell to hang waiting for an incorrect - job pid has been fixed. + job PID has been fixed. 12-01-19 A memory leak which occurred for a nested command substitution has been fixed. 12-01-17 A bug in which typeset -u PS1 could enable the uppercase attribute @@ -312,12 +312,12 @@ ____ with more than twenty-five open files has been fixed. 11-10-06 A bug in the scoping of name references in functions called by other functions has been fixed. -11-10-05 A bug in which wait on a pid may return the exit status of an - earlier background job with that pid instead has been fixed. +11-10-05 A bug in which wait on a PID may return the exit status of an + earlier background job with that PID instead has been fixed. 11-09-22 A bug in which a read timed out with TMOUT did not always restore the terminal state has been fixed. 11-09-21 An optimization that allowed the last command in a script to use - the same process id as the script has been eliminated. + the same process ID as the script has been eliminated. 11-09-21 Added letoctal option that enables the let command to recognize octal constants starting with 0. 11-09-20 A bug in which ${var.} could cause a core dump has been fixed. @@ -394,7 +394,7 @@ ____ been fixed. 11-05-02 A bug in which the shell discards saved exit status of a job if it is followed by a subshell execution has been fixed. -11-04-28 The shell now checks for numerical overflows with process ids. +11-04-28 The shell now checks for numerical overflows with process IDs. 11-04-28 Another scoping bug with compound variables defined by name references inside a function has been fixed. 11-04-28 A bug which caused a core dump on 32 bit systems with the basic.sh @@ -684,7 +684,7 @@ ____ 10-08-09 +Modified the expansion of message strings, $"...", so that they are expanded each time they are referenced rather than expanding them when the script is compiled or read in. -10-08-06 +The process id for jobs in job pools is now of the form poolname.n +10-08-06 +The process ID for jobs in job pools is now of the form poolname.n where n is the jobid in that pool. Commands that accept job names or numbers now understand names in this format. 10-08-05 A bug in which an assignment from within an arithmetic expression @@ -973,7 +973,7 @@ ____ decimal_point=','. 09-11-02 A bug where "return" in .profile did not restore the shell state has been fixed. -09-10-31 A bug that corrupted saved exit status when pids wrapped around has +09-10-31 A bug that corrupted saved exit status when PIDs wrapped around has been fixed. 09-10-26 A bug in { LANG LC_ALL LC_category } ordering has been fixed in -last. 09-10-16 A bug where notification to libast that the environment has changed @@ -1099,13 +1099,13 @@ ____ 09-03-24 +ksh now only uses the value of the _ variable on startup if it can verify that it was set by the invoking process rather than being inherited by some other ancestor. -09-03-24 +When ksh is invoked without -p and ruid!=euid, and the shell is - compiled without SHOPT_P_UID or ruid=SHOPT_P_UID then euid is set - to ruid. A bug that did the wrong test (ruid= SHOPT_P_UID then EUID is set + to RUID. A bug that did the wrong test (RUID < SHOPT_P_UID) was fixed. 09-03-17 +The sleep(1) builtin now accept and ISO 8601 PnYnMnDTnHnMnS duration or date(1) compatible date/time operand. 09-03-10 If a variable that was left or right justified or zero-filled was @@ -1194,7 +1194,7 @@ ____ of concurrent & jobs to n; the n+1 & job will block until a running background job completes. (2) SIGCHLD traps are queued so that each completing background job gets its own trap; $! is - set to the job pid and $? is set to the job exit status at the + set to the job PID and $? is set to the job exit status at the beginning of the trap. (3) sleep -s added to sleep until the time expires or until a signal is delivered. 08-12-04 The sign of floating point zero is preserved across arithmetic @@ -1214,8 +1214,8 @@ ____ set for an instance could appear twice when displaying the variable has been fixed. 08-11-11 A bug in which running a simple command & inside a function would - not return the correct process id has been fixed. -08-11-10 A bug in which the exit status of a command could be lost if the pid + not return the correct process ID has been fixed. +08-11-10 A bug in which the exit status of a command could be lost if the PID was that of the most recent command substitution that had completed has been fixed. 08-11-10 The maximum depth for subshells has been increased from 256 to 65536. @@ -1369,7 +1369,7 @@ ____ 08-06-09 A bug in which the return value for an assignment command containing a command substitution with that failed was zero when the assignment contained redirections has been fixed. -08-06-09 A bug in the quoting of $ inside a ERE pattern ~(E)(pattern) +08-06-09 A bug in the quoting of $ inside an ERE pattern ~(E)(pattern) has been fixed. 08-06-06 A bug when processing `` command substitution with the character sequence \$' has been fixed. @@ -1710,7 +1710,7 @@ ____ 06-10-26 +The printf modifier # when used with d produces units in thousands with a single letter suffix added. The modifier # when used with the i specification provides units of 1024 with a two letter suffix. -06-10-24 The value of $! is now set to the process id of a job put +06-10-24 The value of $! is now set to the process ID of a job put into the background with the bg command as required by POSIX. 06-10-23 A bug in which the value of $! was affected by a background job started from a subshell has been fixed. @@ -1735,7 +1735,7 @@ ____ is only needed when using the ([subscript]=value ...) form. 06-09-06 +The showme option was added. Each simple command not beginning with a redirection and not occurring with in the while, until, if, - select condition can be preceded by a semi-colon which will + select condition can be preceded by a semicolon which will be ignored when showme is off. When showme is on, any command preceded by a colon will be traced but not executed. 06-08-16 +As a new feature, a leading ~(N) on a pattern has no effect @@ -2487,7 +2487,7 @@ ____ were previously processed in undefined ways. 01-05-09 A bug in which the output of select was not flushed before the read when input did not come from the terminal has been fixed. -01-05-08 A bug in which job ids would not be freed for interactive shells +01-05-08 A bug in which job IDs would not be freed for interactive shells when subshells ran built-ins in the background has been fixed. 01-05-08 +The FPATH variable now requires an explicit . to cause the current directory to be treated as a function directory. diff --git a/src/cmd/ksh93/SHOPT.sh b/src/cmd/ksh93/SHOPT.sh index 23a6ec0a0..9eab02901 100644 --- a/src/cmd/ksh93/SHOPT.sh +++ b/src/cmd/ksh93/SHOPT.sh @@ -32,13 +32,13 @@ 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 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 SHOPT REMOTE= # enable --rc if running as a remote shell SHOPT SPAWN= # use spawnveg for fork/exec SHOPT STATS=1 # add .sh.stats variable -SHOPT SUID_EXEC=1 # allow (safe) suid/sgid shell scripts +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 diff --git a/src/cmd/ksh93/bltins/regress.c b/src/cmd/ksh93/bltins/regress.c index b74b4b97a..7fd10b102 100644 --- a/src/cmd/ksh93/bltins/regress.c +++ b/src/cmd/ksh93/bltins/regress.c @@ -66,31 +66,31 @@ static const char usage[] = "the specific intercept for \aoption\a, and \ainfo\a is \aoption\a " "specific information. Unless noted otherwise, one regression test trace " "line is produced each time an enabled intercept is called.]" -"[101:egid?The intercept effective gid is set to \aoriginal-egid\a. The " - "effective gid of the underlying system process is not affected. The " +"[101:egid?The intercept effective GID is set to \aoriginal-egid\a. The " + "effective GID of the underlying system process is not affected. The " "trace line info is either \begid==rgid\b or \begid!=rgid\b. The " "intercepts are:]#?[original-egid:=1]" "{" - "[+getegid()?The intercept effective gid is returned. The " - "\bsetgid\b() intercept may change this between the real gid and " + "[+getegid()?The intercept effective GID is returned. The " + "\bsetgid\b() intercept may change this between the real GID and " "\aoriginal-egid\a.]" - "[+setgid(gid)?Sets the intercept effective gid to \agid\a. " - "Fails if \agid\a is neither the real gid nor " + "[+setgid(gid)?Sets the intercept effective GID to \agid\a. " + "Fails if \agid\a is neither the real GID nor " "\aoriginal-egid\a.]" "}" -"[102:euid?The intercept effective uid is set to \aoriginal-euid\a. The " - "effective uid of the underlying system process is not affected. The " +"[102:euid?The intercept effective UID is set to \aoriginal-euid\a. The " + "effective UID of the underlying system process is not affected. The " "trace line info is either \beuid==ruid\b or \beuid!=ruid\b. The " "intercepts are:]#?[original-euid:=1]" "{" - "[+geteuid()?The intercept effective uid is returned. The " - "\bsetuid\b() intercept may change this between the real uid and " + "[+geteuid()?The intercept effective UID is returned. The " + "\bsetuid\b() intercept may change this between the real UID and " "\aoriginal-euid\a.]" - "[+setuid(uid)?Sets the intercept effective uid to \auid\a. " - "Fails if \auid\a is neither the real uid nor " + "[+setuid(uid)?Sets the intercept effective UID to \auid\a. " + "Fails if \auid\a is neither the real UID nor " "\aoriginal-euid\a.]" "}" -"[103:p_suid?Specifies a value for SHOPT_P_SUID. Effective uids greater " +"[103:p_suid?Specifies a value for SHOPT_P_SUID. Effective UIDs greater " "than the non-privileged-uid disable the privileged mode. The intercepts " "are:]#?[non-privileged-uid:=1]" "{" @@ -146,7 +146,7 @@ void sh_regress(unsigned int index, const char* intercept, const char* info, uns } /* - * egid intercepts + * EGID intercepts */ static gid_t intercept_sgid = 0; @@ -189,7 +189,7 @@ int setgid(gid_t gid) } /* - * euid intercepts + * EUID intercepts */ static uid_t intercept_suid = 0; diff --git a/src/cmd/ksh93/bltins/test.c b/src/cmd/ksh93/bltins/test.c index 26c531739..3b9e25c93 100644 --- a/src/cmd/ksh93/bltins/test.c +++ b/src/cmd/ksh93/bltins/test.c @@ -595,7 +595,7 @@ int test_inode(const char *file1,const char *file2) /* - * This version of access checks against effective uid/gid + * This version of access checks against the effective UID/GID * The static buffer statb is shared with test_mode. */ @@ -612,15 +612,15 @@ int sh_access(register const char *name, register int mode) if(sh.userid==sh.euserid && sh.groupid==sh.egroupid) return(access(name,mode)); #ifdef _lib_setreuid - /* swap the real uid to effective, check access then restore */ - /* first swap real and effective gid, if different */ + /* swap the real UID to effective, check access then restore */ + /* first swap real and effective GID, if different */ if(sh.groupid==sh.euserid || setregid(sh.egroupid,sh.groupid)==0) { - /* next swap real and effective uid, if needed */ + /* next swap real and effective UID, if needed */ if(sh.userid==sh.euserid || setreuid(sh.euserid,sh.userid)==0) { mode = access(name,mode); - /* restore ids */ + /* restore IDs */ if(sh.userid!=sh.euserid) setreuid(sh.userid,sh.euserid); if(sh.groupid!=sh.egroupid) diff --git a/src/cmd/ksh93/bltins/typeset.c b/src/cmd/ksh93/bltins/typeset.c index aef8a55f7..5d88c34c0 100644 --- a/src/cmd/ksh93/bltins/typeset.c +++ b/src/cmd/ksh93/bltins/typeset.c @@ -1556,7 +1556,7 @@ static void print_attribute(register Namval_t *np,void *data) /* * print the nodes in tree which have attributes set - * of