mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +00:00
POSIX compliance: rm harmful default aliases 'command '/'nohup '
Continuing alias substitution after 'command' (due to the final space in the alias) is inherently broken and doing so by default is incompatible with the POSIX standard, as aliases may contain arbitrary shell grammar. For instance, until the previous commit, the POSIX standard 'times' command was an alias: times='{ { time;} 2>&1;}' -- and so, of course, 'command times' gave a syntax error, although this is a perfectly valid POSIX idiom that must be supported. 'command' is specified by POSIX as a regular builtin, not an alias. Therefore it should always bypass aliases just as it bypasses functions to expose standard builtin and external commands. I can only imagine that the reason for this command='command ' alias was that some standard commands themselves were implemented as aliases, and POSIX requires that standard commands are accessible with the 'command' prefix. But implementing standard commands as aliases is itself inherently broken. It never worked for 'command times', as shown; and in any case, removing all aliases with 'unalias -a' should not get rid of standard commands. Similarly, the default alias nohup='nohup ' is also harmful. Anyone who really wants to keep this behaviour can just define these aliases themselves in their script or ~/.kshrc file. src/cmd/ksh93/data/aliases.c: - Remove default alias command='command '. - Remove default alias nohup='nohup '. src/cmd/ksh93/sh.1 - Remove the above default aliases from the list. - Mention that the 'command' builtin does not search for aliases. (cherry picked from commit 5cfe7c4e2015b7445da24983af5008035c4b6e1e)
This commit is contained in:
parent
65d363fd34
commit
61d9bca581
4 changed files with 7 additions and 27 deletions
6
NEWS
6
NEWS
|
@ -12,6 +12,12 @@ Any uppercase BUG_* names are modernish shell bug IDs.
|
|||
another with those used by all of the shell's child processes.
|
||||
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_27
|
||||
|
||||
- The default aliases command='command ' and nohup='nohup ' have been
|
||||
removed because they caused breakage in an attempt to circumvent other
|
||||
breakage which is being fixed. In the unlikely even that anyone still
|
||||
needs alias substitution to continue on the command argument following
|
||||
'command' or 'nohup', it's easy to set these aliases yourself.
|
||||
|
||||
2020-06-05:
|
||||
|
||||
- Fix a bug that caused special variables such as PATH, LANG, LC_ALL,
|
||||
|
|
20
TODO
20
TODO
|
@ -10,29 +10,9 @@ Fix build failures:
|
|||
|
||||
- ksh does not currently build on AIX, HP-UX, Solaris, or QNX.
|
||||
|
||||
______
|
||||
Remove hack for 'test -t' with no args == 'test -t 1':
|
||||
- from sh/parse.c, qscan()
|
||||
- from bltins/test.c
|
||||
|
||||
______
|
||||
Fix or remove broken default aliases:
|
||||
|
||||
- Remove alias times='{ { time;} 2>&1;}' which does not produce POSIX-
|
||||
compliant output; reimplement as a proper POSIX-compliant builtin.
|
||||
In any case, implementing a standard utility as an alias is unacceptable
|
||||
as 'unalias -a' (remove all aliases) should not remove standard utilities!
|
||||
Backport the builtin from the abandoned Vashisht/Rader branch:
|
||||
https://github.com/att/ast/pull/1332
|
||||
|
||||
- Remove alias command='command '. Continuing alias substitution after
|
||||
'command' (due to the final space in the alias) is inherently broken, as
|
||||
aliases may contain arbitrary shell grammar. For instance, when combining
|
||||
this default alias with the default 'times' alias ('command times'), which
|
||||
is perfectly valid per POSIX, you get a syntax error!
|
||||
|
||||
- Remove alias nohup='nohup '. Same reason as for 'command ' above.
|
||||
|
||||
- Remove pointless default aliases 'fc' and 'type'; these are already
|
||||
implemented as normal shell builtins. Add man page entries for these.
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ const struct shtable2 shtab_aliases[] =
|
|||
"2d", NV_NOFREE, "set -f;_2d",
|
||||
#endif /* SHOPT_FS_3D */
|
||||
"autoload", NV_NOFREE, "typeset -fu",
|
||||
"command", NV_NOFREE, "command ",
|
||||
"compound", NV_NOFREE|BLT_DCL, "typeset -C",
|
||||
"fc", NV_NOFREE, "hist",
|
||||
"float", NV_NOFREE|BLT_DCL, "typeset -lE",
|
||||
|
@ -42,7 +41,6 @@ const struct shtable2 shtab_aliases[] =
|
|||
"history", NV_NOFREE, "hist -l",
|
||||
"integer", NV_NOFREE|BLT_DCL, "typeset -li",
|
||||
"nameref", NV_NOFREE|BLT_DCL, "typeset -n",
|
||||
"nohup", NV_NOFREE, "nohup ",
|
||||
"r", NV_NOFREE, "hist -s",
|
||||
"redirect", NV_NOFREE, "command exec",
|
||||
"source", NV_NOFREE, "command .",
|
||||
|
|
|
@ -790,8 +790,6 @@ but can be unset or redefined:
|
|||
.TP
|
||||
.B "autoload=\(fmtypeset \-fu\(fm"
|
||||
.TP
|
||||
.B "command=\(fmcommand \(fm"
|
||||
.TP
|
||||
.B "compound=\(fmtypeset \-C\(fm"
|
||||
.TP
|
||||
.B "fc=hist"
|
||||
|
@ -808,8 +806,6 @@ but can be unset or redefined:
|
|||
.TP
|
||||
.B "nameref=\(fmtypeset \-n\(fm"
|
||||
.TP
|
||||
.B "nohup=\(fmnohup \(fm"
|
||||
.TP
|
||||
.B "r=\(fmhist \-s\(fm"
|
||||
.TP
|
||||
.B "redirect=\(fmcommand exec\(fm"
|
||||
|
@ -5811,7 +5807,7 @@ the operating system's standard utilities path
|
|||
rather than the one defined by the value of
|
||||
.SM
|
||||
.BR PATH .
|
||||
Functions will not be searched for when finding
|
||||
Functions and aliases will not be searched for when finding
|
||||
.IR name .
|
||||
In addition, if
|
||||
.I name\^
|
||||
|
|
Loading…
Reference in a new issue