1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

POSIX compliance fix: make 'unalias' a regular builtin

Both 'alias' and 'unalias' are specified as regular builtins. Among
a few other things, that means it ought to be portable to use these
names for shell functions. But ksh93 disallowed that until now.

src/cmd/ksh93/data/builtins.c:
- Make 'unalias' a regular builtin by removing the BLT_SPC flag.
- (same fix for 'alias' was already done in afa68dca)
- Add the BLT_ENV flag to the 'alias' and 'hash' commands. In
  include/name.h, this flag is commented: "non-stoppable, can
  modify environment". The "non-stoppable" bit seems like a good
  idea: these operations should not be interruptable as that would
  cause an inconsistent state.

src/cmd/ksh93/sh.1:
- Remove the '-', indicating special builtin, from 'alias' entry.
- Minor cosmetic fix: space after the '-' for 'unset'.

(cherry picked from commit a4315d7672204acb543010b4d4916b22dcb9cb08)
This commit is contained in:
Martijn Dekker 2020-06-11 12:43:17 +02:00
parent 2da22f4023
commit 04b9171858
4 changed files with 15 additions and 9 deletions

6
NEWS
View file

@ -4,6 +4,12 @@ For full details, see the git log at:
Any uppercase BUG_* names are modernish shell bug IDs. Any uppercase BUG_* names are modernish shell bug IDs.
2020-06-11:
- POSIX compliance fix: It is now possible to set shell functions named
'alias' or 'unalias', overriding the commands by the same names. In
technical terms, they are now regular builtins, not special builtins.
2020-06-10: 2020-06-10:
- The 'hash' utility is now a regular builtin instead of an alias to - The 'hash' utility is now a regular builtin instead of an alias to

View file

@ -56,7 +56,7 @@
*/ */
const struct shtable3 shtab_builtins[] = const struct shtable3 shtab_builtins[] =
{ {
"login", NV_BLTIN|BLT_ENV|BLT_SPC, Bltin(login), "login", NV_BLTIN|BLT_ENV, Bltin(login),
"exec", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(exec), "exec", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(exec),
"set", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(set), "set", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(set),
":", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(true), ":", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(true),
@ -76,11 +76,11 @@ const struct shtable3 shtab_builtins[] =
"local", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(typeset), "local", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(typeset),
#endif #endif
#if _bin_newgrp || _usr_bin_newgrp #if _bin_newgrp || _usr_bin_newgrp
"newgrp", NV_BLTIN|BLT_ENV|BLT_SPC, Bltin(login), "newgrp", NV_BLTIN|BLT_ENV, Bltin(login),
#endif /* _bin_newgrp || _usr_bin_newgrp */ #endif /* _bin_newgrp || _usr_bin_newgrp */
"alias", NV_BLTIN, bltin(alias), "alias", NV_BLTIN|BLT_ENV, bltin(alias),
"hash", NV_BLTIN, bltin(alias), "hash", NV_BLTIN|BLT_ENV, bltin(alias),
"enum", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(enum), "enum", NV_BLTIN|BLT_ENV|BLT_DCL, bltin(enum),
"eval", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_EXIT,bltin(eval), "eval", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_EXIT,bltin(eval),
"exit", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return), "exit", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return),
"fc", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist), "fc", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
@ -88,7 +88,7 @@ const struct shtable3 shtab_builtins[] =
"readonly", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(readonly), "readonly", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(readonly),
"shift", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(shift), "shift", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(shift),
"trap", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(trap), "trap", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(trap),
"unalias", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(unalias), "unalias", NV_BLTIN|BLT_ENV, bltin(unalias),
"unset", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(unset), "unset", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(unset),
"builtin", NV_BLTIN, bltin(builtin), "builtin", NV_BLTIN, bltin(builtin),
#if SHOPT_ECHOPRINT #if SHOPT_ECHOPRINT

View file

@ -17,4 +17,4 @@
* David Korn <dgk@research.att.com> * * David Korn <dgk@research.att.com> *
* * * *
***********************************************************************/ ***********************************************************************/
#define SH_RELEASE "93u+m 2020-06-10" #define SH_RELEASE "93u+m 2020-06-11"

View file

@ -7738,7 +7738,7 @@ option causes the mode to be printed as a symbolic
value. Otherwise, the value. Otherwise, the
mask is printed in octal. mask is printed in octal.
.TP .TP
\(dg \f3unalias\fP \*(OK \f3\-a\fP \*(CK \f2name\^\fP .\|.\|. \f3unalias\fP \*(OK \f3\-a\fP \*(CK \f2name\^\fP .\|.\|.
The aliases The aliases
given by the list of given by the list of
.IR name s .IR name s
@ -7748,7 +7748,7 @@ The
option causes all the option causes all the
aliases to be unset. aliases to be unset.
.TP .TP
\(dg\f3unset\fP \*(OK \f3\-fnv\fP \*(CK \f2vname\^\fP .\|.\|. \(dg \f3unset\fP \*(OK \f3\-fnv\fP \*(CK \f2vname\^\fP .\|.\|.
The variables given by the list of The variables given by the list of
.IR vname s .IR vname s
are unassigned, are unassigned,