Commit Graph

121 Commits

Author SHA1 Message Date
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
tg b145ca5c9f • sync distrib/special/mksh/Makefile with bin/mksh/Build.sh and
fix the regression test’s results while here, which have been
  broken since cid 10049D9BE5254CE65B8
• get rid of separate copyright file which was intended for De-
  bian; track down commits in all files of oksh-mirbsd and mksh
  to get correct copyright years per-file, as is BSD custom
2009-05-16 16:59:42 +00:00
tg 43de9f8dff shorten 2009-04-05 12:42:34 +00:00
tg 177b1b4cf9 always set COLUMNS and LINES; make use of the fact in dot.mkshrc 2008-12-29 21:34:22 +00:00
tg 553ff601b7 optimise: embed ^A and ^M inside the default PS1 string 2008-12-13 17:09:45 +00:00
tg 5206ddcc65 much simplify and shorten default $PS1 (uses even more magick now) 2008-11-07 20:07:10 +00:00
tg b41a72ac2e add new builtin “realpath” calling realpath(3) on its argument, skipping
over “--” for compatibility to Debian realpath(1) and possibly busybox’

“sounds handy” replaced@TNF
2008-05-17 18:27:57 +00:00
tg 4e4ede2442 fix for $HOME with trailing slash (do not expand then either… we could just
strip it, but that might have other problems, better is to use realpath(2),
e.g. via readlink(1), for normalisation, or have the sysop fix it)

XXX make realpath a builtin?
2008-05-16 22:22:11 +00:00
tg 8cf7c94908 if $HOME is / or empty, bash-style tilde replacement yielded funny results 2008-05-16 22:19:11 +00:00
tg 6be5205b36 mksh:
* initialise the integers PPID, OPTIND, RANDOM, SECONDS, and TMOUT to base-10
* bring back PGRP as base-10 integer to the process group via getpgrp(2)
* initialise USER_ID as base-10 integer to the effective user id as retrieved
  from geteuid(2) = $(id -u)
* use $USER_ID in dot.mkshrc instead of spawning an id(1) process
  -> dot.mkshrc,v 1.34 now requires mksh R34
* convert more int to bool where appropriate
* remove dead code - getpgrp(2) cannot fail
* sync manual page to reality
* bump to mksh R34(beta) - feature freeze

XXX check if our_pgrp in jobs.c is still really needed, the setpgid call
XXX probably just makes us our own pgrp leader, and we might have to use
XXX and update kshpgrp accordingly - need feedback/help here but I think
XXX this simplification should be possible if I grok the code correctly.

etc/profile:
* adjust to $USER_ID changes in mksh (speed-up here, too)

mksh.hts:
* sync changelog
2008-05-15 15:24:11 +00:00
tg e57f5fc09b • be friendlier to AT&T ksh: use only signed (standard) integers
‣ now, a “ksh93” just requires ‘function precmd { :; }; set -o emacs’
    afterwards to get rid of the annoying error messages
  ‣ I could lose that with the following idiom:
    - PS1='$(precmd)…
    + PS1='$(typeset -i e=$?; typeset -f precmd >&- && { (return $e); precmd })…
    but it didn’t seem worthwhile to me
• remove explicit licence blah, normal ./copyright applies
2008-04-22 13:48:15 +00:00
tg 4ff0ca0f86 improve the use (parsing) of “set +o” output in the examples 2008-04-19 22:03:19 +00:00
tg 92eb2aee78 • make sure “ls” is no shell alias:
‣ first alias ls=ls to define it (so that unalias won’t fail)
  ‣ then unalias ls
• don’t hardcode /bin/ls path
2008-04-11 20:14:02 +00:00
tg 09318a472b no longer make the DIRSTACKBASE variable read-only – it makes too much
trouble when re-reading .mkshrc, and “we sell rope” after all
2008-03-03 20:22:37 +00:00
tg 047da7a0eb simplify 2008-03-03 18:44:32 +00:00
tg 947bc8e05b finally, all bugs fixed, adjust dot.mkshrc to use the subst code 2008-03-01 21:24:58 +00:00
tg 015e334ccf oops. forgot to commit:
• bump © year
• document better too
• optimise
2008-03-01 16:35:30 +00:00
tg 8d170a3d01 fix on Interix, where tr(1) is more weird than even Solaris’ XPG4 one…
just do not use ranges, no matter what.
2008-02-29 16:38:41 +00:00
tg 3e870cb1a5 handle slowlaris idiotic /usr/xpg4/bin/tr(1) 2008-02-29 11:48:32 +00:00
tg e56a49adb1 small optimisations 2007-10-25 14:54:00 +00:00
tg 60dfd05620 enable to use colour escapes framed with ^A by default 2007-10-02 01:03:12 +00:00
tg 1086ebe83f • reduce number of readlink(1) / realpath(3) calls by caching the result of
running it on “~/.” (must be a directory) in a global readonly variable
• if readlink fails, use some more or less sane values (no idea what csh(1)
  does in these cases, maybe some feedback here?)
• optimise, while here
2007-09-25 22:36:36 +00:00
tg 9533756d25 use precmd() to do the errorlevel-display dance, so that yofuh can disable
it more easily, and it got an actual use case
2007-09-25 15:48:45 +00:00
tg f632120cc2 by popular request, add
• dirs, pushd, popd like ports/shells/csh (Berkeley C shell)
• precmd, chpwd like ports/shells/zsh (Z shell)
and implement keeping ${DIRSTACK[0]} up to date via chpwd()
instead of doing it on entry of pushd and dirs (so that it
can be used directly)

this is slow compared to earlier, but people seem to want it
2007-09-24 20:30:04 +00:00
tg 7ddc3d788f disable annoying privacy invasion, fight the Überwachungsstaat 2007-09-03 09:25:05 +00:00
tg b9da9d4ea3 if the shell doesn't know the cwd, “builtin pwd” won't either 2007-07-26 13:37:21 +00:00
tg 3a563948ec accomodate stupid Slackware 11 (if you're a slack user, pity you) 2007-06-20 13:38:18 +00:00
tg a7ce246a37 if invoked as /bin/sh, -sh, sh.static, whatever, activate FPOSIX
this should help inferiour operating systems like Debian… (where
some of the devs, hi waldi@, don't consider stop() { } invalid…)
2007-06-15 22:00:00 +00:00
tg c54a614574 useful alias for embedded ones, speedup for all 2007-05-25 13:51:42 +00:00
tg 9e44be4713 oops, can't use single quotes inside of singly quoted string, of course… 2007-05-19 16:35:02 +00:00
tg 9e21d616bd • whence -p can take closing fd 2 instead of pointing it to /dev/null
• hostname and id should too, besides it's mostly for the shell error
  message of not finding them anyway…
• shorten
2007-05-19 16:33:10 +00:00
tg dc71f9b775 • remove an unneeded pair of double quotes
• convert another pair of 'em to “…”
2007-04-17 20:07:09 +00:00
tg b2d0d57468 change our coding style for shell:
we already do not 'function\nfoo\n{' for shell, like style(9) requires for
C programming, but 'function foo\n{' instead. however, we could treat the
function keyword as indentation initialiser and use 'function foo {' (on a
line for itself) – it looks different, unusual, but acceptable, and mksh's
own output (dumping with the “functions” builtin) does that too (although,
its indentation style sucks, but is legible enough)
2007-04-17 20:04:08 +00:00
tg 9cbff5af67 escape the quoting hell, use a function
tested on Interix
2007-04-17 20:00:37 +00:00
tg c79cacdfa5 • from a MirOS point of view:
place most stuff from /etc/profile in /etc/skel/.mkshrc; admins must make
  sure to copy this file to users' homes on upgrade (benefit: non-login but
  interactive shells also get all the goodies); fix some quoting; simplify,
  reformat, change comments
• from an mksh point of view:
  slight internal changes in dot.mkshrc; external commands are now prefixed
  with “ulimit -c 0”; $TERM is defined; improvement in determining the host
  name (e.g. on Debian if a FQDN is not given); declare locals as such both
  in $PS1 and outside; remove superfluous quoting, quote properly; simplify
  hd alias, add rot13 alias; place RCS ID at the bottom
2007-04-16 18:54:37 +00:00
tg 2edb96e663 add a 'true' at the end, to not start with an errorlevel >0 2007-03-04 06:20:48 +00:00
tg 83c2ee87f4 • remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
  that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
  only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
  to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version

¹) side effect from creating API-correct cstrchr, cstrstr, etc.
   uses goto so it must be better ☻

tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 03:04:28 +00:00
tg 6661a2b408 optimise away, this had not let me sleep; still the same output
shell quoting mystery ;)
2007-02-17 06:34:46 +00:00
tg 26adf9d62d fix superfluous spaces appearing twice at the line continuation
points and expanding to larger than 80c, major oops, cought on fwrt
2007-02-17 06:04:48 +00:00
tg 8a59ee0311 * mention additions go at the bottom (e.g. 'source' scripts), in case
they fail (due to nonexistence), so that the rest is still executed
* export $MKSH (users can set SHELL=$MKSH here, but I'm conservative)
2007-01-04 23:40:50 +00:00
tg 30f6ebb2a3 * add the 'hd' alias for hexdump from etc_profile
* optimise
2006-08-28 01:34:47 +00:00
tg 1c9a925139 rewrite stripcom/Lstripcom function, making use of the 'last command
of a pipeline is executed in a subshell' trick, don't use co-process
(because that's verbose twice in an interactive shell profile), move
the noglob block into the while and rid the redundant +o and local.
2006-08-14 20:32:44 +00:00
tg f1e8f970c4 * get dot.mkshrc sample from Debian mksh-27.4-2
* sync dot.mkshrc sample with FreeWRT r383
* add some stuff from src/etc/profile and contrib/samples/etc_profile
* sync the latter two with reality and shorten
* teach the user in the mksh installation instructions to install the sample

NB: the sample is also covered by the MirOS licence
2006-07-23 18:44:22 +00:00