Commit Graph

92 Commits

Author SHA1 Message Date
tg 8f53c68265 • 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
2015-03-08 22:54:36 +00:00
tg 59fcff27ae • fix bug spotted by geirha: typeset args are glob-prone
• ormaaj suggested adding gsf’s homepage (still no new ast-ksh)
2015-01-11 00:23:06 +00:00
tg d048818dfa • when using typeset to change the type of an array,
use arrname[*] to denote changing it of all array elements
• optimise a bit: group local invocations
2015-01-06 20:54:53 +00:00
tg 097ed42c83 https://android-review.googlesource.com/102253
• 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
2014-07-28 21:45:45 +00:00
tg 270a86f895 • use BAFH for hash ipv NZAAT
• prep for release
• fix minor nits in manpage and tests
2014-01-11 18:09:43 +00:00
tg 95a19997b8 avoid NZATMix returning false on its identity mapping (00000000h) 2014-01-05 22:17:57 +00:00
tg 0545eb1c45 • use Rijndæl MixColumn for arc4random_roundhash avalanching;
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)
2014-01-02 22:51:01 +00:00
tg 75c00ebaae • don’t eat builtin cd errorlevel in function cd
• fix extglob in function cd_csh to match current error strings
2013-08-22 13:46:46 +00:00
tg 1d487d9163 by request of gecko2@ make “doch” keep stdin at slight lack of privacy 2013-08-10 13:43:50 +00:00
tg 35710c6461 disable utf8-mode for hd function (temporarily) 2013-07-25 14:02:02 +00:00
tg 1d0409d932 implement VALSUBs 2013-05-02 21:59:54 +00:00
tg 54a698d564 pimp the hexdump function 'hd' for when there is none 2013-05-02 21:46:29 +00:00
tg c3b93834b0 lksh also reads $ENV so make sure it doesn’t try this one 2013-04-27 18:19:44 +00:00
tg 1a21176cac Tonnerre Lombard’s contribution:
[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…
2013-04-05 15:39:52 +00:00
tg 8697048c2c set (but never export!) PS4 to something timestamped by default, as an example 2013-03-24 15:01:35 +00:00
tg 576b7f21b3 eval is evil
Proper quoting is hard
Bugs galore
2013-02-17 15:58:26 +00:00
tg 9bf0509829 provide a layer of locality to FUNSUBs; get rid of a fork for each PS1 thus 2013-02-10 23:30:47 +00:00
tg af39f3b7b0 do NOT close stdout or stderr, redirect to /dev/null instead
⇒ we did have issues with that, trust me…
2013-02-10 19:04:00 +00:00
tg 72c895c4a1 precmd is required to retain the errorlevel when ${ …;} is used 2013-01-21 15:06:24 +00:00
tg 0f3071a8b2 MKSH_DISABLE_EXPERIMENTAL is a NOP again; use ${ precmd;} in dot.mkshrc 2012-11-30 20:19:16 +00:00
tg bbc0702cdd make “set -o nounset” friendly (even though people who use THAT are at own fault, IMO!) 2012-10-30 21:04:56 +00:00
tg bb5e56d4c4 remove ${ foo;} from mksh again due to buffering issues jilles found 2012-08-17 18:34:25 +00:00
tg 9b7b7f742e implement ksh93 feature ${ foo;} 2012-07-30 21:37:17 +00:00
tg 25f413bf7d first part of LP: #909818; ${name@#} will later be changed to ${name@#expr} where expr is the IV ipv 0 (eval.c:377ff) 2011-12-31 01:07:19 +00:00
tg 0d2244da81 use += and do some more mitigation of the alloc problem first 2011-11-25 23:58:04 +00:00
tg 5c1108c5fa actually… the error paths didn’t se-unset noglob! after looking at the
code, until further proof I believe noglob is not even needed ⇒ drop it
2011-11-25 23:54:06 +00:00
tg 5ac24244fd == inside [[ is not nice, and parsing $(set +o) isn’t either,
since we don’t just have [[ -o ]] now, but can use standard $- here
2011-11-25 23:43:59 +00:00
tg 577c918beb patch most of Jerker Bäck’s concerns out, unless not applicable 2011-08-27 18:06:52 +00:00
tg 6ce68e906f now that I got Hash.cs compiled and run, I’m amazed; make NZAAT (and NZAT!) all green with a small tweak; bit distribution and χ2 look OK as well 2011-07-18 00:35:46 +00:00
tg 3ef67e3296 replace uses of OAAT hash in all its variants by NZAT (mksh internal) or NZAAT (all others) 2011-07-06 22:22:02 +00:00
tg fe2c0221b3 replace typeset with local, as style(9) now mandates
(keep globals for a while, until it’s widespread, though)

since we don’t export PS1 any longer, no need to stay AT&T ksh compatible
2011-07-05 20:19:18 +00:00
tg 02b76603f8 new function for dot.mkshrc:
23:19⎜<laffer1:#midnightbsd> oddly enough the only cshism i like is setting environment variables at this point.
2011-07-03 23:26:47 +00:00
tg 2cfc3e5c3d mksh R40 Release Candidate 1
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
2011-05-29 02:18:57 +00:00
tg 4e626ecc30 add smores, a more(1)-like pager 2011-02-09 19:32:35 +00:00
tg 1c4aab3a3e when setting a UTF-8 locale, also set -o utf8-mode
since we might start on e.g. GNU/Linux with a system-wide C locale
2011-02-02 22:48:15 +00:00
tg beba20ea56 since dot.mkshrc is sourced by interactive shells anyway, and exporting
PS1 may hurt other shells, do not export it any more

reported by and fix suggestion / affected variables by Frank Terbeck
2010-11-26 21:08:54 +00:00
tg 0a5d6bc71b use string width, not length, if we have it 2010-07-11 13:54:37 +00:00
tg f878310b58 fix spelling 2010-07-04 17:35:16 +00:00
tg 0d484ffa65 some OSes pre-define $ENV; let this be another hint to their users 2010-02-25 20:48:10 +00:00
tg bbb4a1a70f add Loaathash1 (iv=0x100 ipv 0) 2010-01-25 14:29:34 +00:00
tg 01823e0e11 use [[ -o … ]] instead of [[ $- = *U* ]] manipulation 2009-12-12 22:27:14 +00:00
tg 6e9d7f33e8 like a pathfinder, one good commit a day:
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.)
2009-11-03 17:58:44 +00:00
tg 9008fe34a2 unalias which, to allow which -a sh, etc. 2009-11-02 18:47:02 +00:00
tg 345030a578 we need more RCS IDs! 2009-08-27 16:52:12 +00:00
tg b5b5d905b0 various fixes and optimisations:
• 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
2009-08-27 16:40:08 +00:00
tg 4c1a99da7c implement Jenkins’ one-at-a-time hash, which has better avalanche
behaviour than DJB’s CDB hash (good if using more than one byte)
and probably no funnels

the CDB hash is good for short (5-6 char) ASCII keys though
2009-08-27 16:29:21 +00:00
tg fb6d8cd895 this is Korn Shell, not C – less ops are always faster than many fast ops 2009-08-27 16:03:52 +00:00
tg fd0ddd5902 add a DJB cdb hash implementation in mksh, which, for speed, uses a
global variable ipv print’ing the result for reparse. conveniently,
it’s already typeset just right (unsigned hex integer, zero padded)
2009-06-22 17:38:39 +00:00
tg 261cabad23 fix $@ vs $* mix-up 2009-06-22 17:27:22 +00:00
tg 804fe16118 add base64 decoder and encoder in mksh 2009-05-31 17:17:33 +00:00