• protect POSIX builtins and utilities from aliases, e.g:

‣ : → \:
  ‣ alias → \alias
    ⇒ except in some internally used cases, where we use \builtin alias
  ‣ command . → \command .
• protect Korn Shell builtins from aliases and functions, e.g:
  ‣ typeset → \builtin typeset
    ⇒ also unravels the “local” alias used
  ‣ print → \builtin print
• protect internally-used things from aliases
  ‣ “let]” is not a valid function name
  ‣ “set” is POSIX so we don’t expect anyone to override it in a function
• use “command -v” instead of “whence -p” (“which”) in most
  places; thanks izabera from #ed on IRC for pointing out
  that “command -v” is POSIX – except, “whence -p” a̲l̲w̲a̲y̲s̲ looks
  for an executable and shows its full pathname; “command -v”
  also resolves to aliases, functions and builtins, so only use
  it where it makes any sense (both never output to stderr)
• make most of dot.mkshrc work in the face of such aliases
  ‣ “ulimit -c” is used; this is not POSIX, and not portable;
    maybe we should make ulimit accept-and-ignore the most
    common limits even if the OS doesn’t use them?
• update list of builtin aliases in the manpage
This commit is contained in:
tg
2015-03-08 22:54:36 +00:00
parent fcc59eee48
commit 8f53c68265
7 changed files with 277 additions and 301 deletions

26
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.288 2015/03/08 21:30:21 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.289 2015/03/08 22:54:33 tg Exp $");
extern char **environ;
@ -66,24 +66,24 @@ static const char *initcoms[] = {
Ttypeset, "-x", "HOME", "PATH", "SHELL", NULL,
Ttypeset, "-i10", "COLUMNS", "LINES", "SECONDS", "TMOUT", NULL,
Talias,
"integer=typeset -i",
Tlocal_typeset,
"integer=\\builtin typeset -i",
"local=\\builtin typeset",
/* not "alias -t --": hash -r needs to work */
"hash=alias -t",
"type=whence -v",
"hash=\\builtin alias -t",
"type=\\builtin whence -v",
#if !defined(ANDROID) && !defined(MKSH_UNEMPLOYED)
/* not in Android for political reasons */
/* not in ARGE mksh due to no job control */
"stop=kill -STOP",
"stop=\\kill -STOP",
#endif
"autoload=typeset -fu",
"functions=typeset -f",
"history=fc -l",
"nameref=typeset -n",
"autoload=\\builtin typeset -fu",
"functions=\\builtin typeset -f",
"history=\\builtin fc -l",
"nameref=\\builtin typeset -n",
"nohup=nohup ",
"r=fc -e -",
"source=PATH=$PATH:. command .",
"login=exec login",
"r=\\builtin fc -e -",
"source=PATH=$PATH:. \\command .",
"login=\\exec login",
NULL,
/* this is what AT&T ksh seems to track, with the addition of emacs */
Talias, "-tU",