• 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…
Testsuite:
• add new need-pass: {yes|no} attribute, default yes
• exit with 1 if a need-pass test failed unexpectedly
idea by Kacper Kornet <draenog@pld-linux.org>
• mark utf8bom-2 as need-pass: no
Infrstructure:
• add housekeeping function for making a tty raw
• switch functions with unused results to void
• struct op: u.charflag contains last char of ;; in TPAT
• var.c:arraysearch is now a global function
Language:
• add ;& (fall through) and ;| (examine next) delimiters
in addition to ;; (end case) as zsh extensions, because
POSIX standardised on ;& already
• add -A (read into array), -N (read exactly n bytes),
-n (read up to n bytes), -t (timeout) flags for read
from ksh93
• allow read -N -1 or -n -1 to slurp the entire input
• add -a (read into array the input characters) extension
specific to mksh to read, idea by David Korn
• add -e (exit with error if PWD was not set correctly
after a physical cd) to cd builtin, mandated by next
POSIX, and change error codes accordingly
Rewrites:
• full rewrite of read builtin and its manpage section
• add regression tetss for most of the new functionality
• duplicate hexdump demo tests for use of read -a
• use read -raN-1 in dot.mkshrc to get NUL safe base64,
DJB cdb hash and Jenkins one-at-a-time hash functions
add most of the mksh wtf edition dot.mkshrc patch, some commented
out; optimise some other cases (e.g. don't reset MKSH if set, don't
export already exported variables, etc.)
• ensure unsigned arithmetics is used in the cdb hash
• make the hash functions print their result again
• now we can use the Lb64{en,de}code trick of using stdin if "$*"==""
• optimise the one-at-a-time code for shell