• if $PWD = ${HOME}foo, no longer show as ~foo in PS1
• simplify ~, ~+, and ~- exactly as $PWD is upon shell entry
(fixes HOME=/home/./foo but PWD=/home/foo)
• do not use \return for return before we know we are mksh
(plus fix a wrong-word mistake)
• quote the argument(s) to \: (“colon”) for SECURITY
• default $MKSH to /bin/mksh (not normally reached)
• while here: check $USER only once, not for each PS1 (speed)
this addresses and mostly closes LP#1441853 – prt.mkshrc (in
OBS home:mirabile/mksh and DEB wtf-mksh they are identical)
is already good; Android mkshrc needs only some small robustness
fixes (mostly colon-related; enh says TMPDIR is good); I tested
this with “mksh -eu” and “mksh -eul” on Debian and ecce and with
read-only “/” and nothing else mounted on ecce, and it WFM
‣ : → \:
‣ 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
• permit interrupts during a write(2) loop in the cat builtin, too,
not just in the read(2) loop – fixes inability to kill a clogged
output cat
• kill the cat when smores finish
TODO: revisit this ⓐ in more depth, ⓑ for other functions, such as
“hd”, and ⓒ test on AOSP as well
suggested in http://crypto.stackexchange.com/questions/12145
• add pure mksh™ implementation, too, while here (since it can
replace NZAATFinish even though NZATMix is slower, both are
bijective)
[17:27:44] Tonnerre: csh: alias doch sudo \!-1 bash: alias doch='sudo $(history -p !-1)' zsh: alias doch='sudo $(fc -ln -1)'
[17:28:03] mirabilos: ?
[17:28:34] Tonnerre: Na ganz einfach:
[17:28:36] Tonnerre: % ls /root
[17:28:39] Tonnerre: ls: cannot open directory /root: Permission denied
[17:28:42] Tonnerre: % doch
[17:28:45] Tonnerre: [sudo] password for tonnerre:
[17:28:49] Tonnerre: anaconda-ks.cfg cgminer-1.6.2-1.rf.src.rpm rpmbuild upgrade.log upgrade.log.syslog
[17:28:53] Tonnerre: %
This is one of two mksh variants; the other uses a tmpfile:
alias doch='sudo mksh -c "${ fc -ln -1;}"'
Both quote correctly, unlike the above.
Maybe use $MKSH instead? (Quoted or unquoted? Hm. Probably quoted.)
Input on that welcome…