Commit Graph

751 Commits

Author SHA1 Message Date
tg 3b87d173d4 • finally, the code and manual page text to deprecate, and code to not
handle any more, octal 010 style constants, as promised
• overhaul the manpage re. arithmetic expressions, make the guarantees
  mksh code has explicitly, precisely, clear
• to reduce burden of the compiler, getint() now operates on mksh_uari_t
  internally; it already applied the sign after operation, anyway (C99
  guarantees wraparound on unsigned types, but for signed types we need
  specific compiler support; apparently, this comes from hardware limits)
• use const and shuffle order of locals around while here
2011-12-10 13:34:19 +00:00
tg 15cfc6c88d add tests for
• integer base flat (10, 010, 0x10)
  ‣ posix, right variants (heh, just like timezones)
  ⇒ both enabled, which means one test always fails right now,
    until the code changes are in…
  ☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
    all use the posux variant
  ☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
  ‣ posix is stupid to use C (strongly typed, compiled) semantics
    for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
  ‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
tg 63b9d60b31 MKSH_DISABLE_DEPRECATED needs testsuite handling 2011-12-08 22:19:04 +00:00
tg 1ac636670f • improve comments
• do shave off 20 bytes from c_test() and get rid of the ugly stack
  variable and double “using” despite not parsing
2011-12-02 22:55:49 +00:00
tg 2fb9df56e4 rewrite funcs.c:c_test(), i.e. test(1) and [(1), to follow POSIX and XSI
in the cases where they are defined unambiguously; bug reported by
Jilles Tjoelker in <20111129232526.GC14357@stack.nl> due to a report
by Stefano Lattarini on bug-autoconf

in the ambiguous case, I stick to traditional pdksh behaviour, which means
	test ! a = b	vs.	test a = b
and
	test ! a -o b	vs.	test a -o b
behave different from each other (in the second case, the NOT operator
binds strong; POSIX demands a reduction to 3 arguments and negating
that result in the first case), so we're at two known not-ok in the
FreeBSD® testsuite. (81 and 82 in regress.sh,v 1.3)
2011-11-30 21:34:15 +00:00
tg 0695039dc0 fix stateptr-underflow; really do call fastbox regression checks; bump vsn 2011-11-26 00:45:21 +00:00
tg 63878e8aef another couple of verbose checks; the *-global are mksh specific but work;
mksh currently fails arrassign-fnc-local (never worked either)
2011-11-25 23:33:42 +00:00
tg 2ff9255f39 add a -f option to test.sh that runs tests of class fastbox
plus a test in that category for a bug spotted during development of
https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=shellsnippets/shellsnippets.git;a=blob;f=mksh/sysadmin/getjpics.cgi;h=d74018cbc1ae4e88408267ecc73a6df19aa4c99a;hb=HEAD
2011-11-25 23:29:31 +00:00
tg dd014625e1 Fix regression introduced by mixing the recursive parser and support
for ;| and ;& in TCASE: ;;-less last casepart produced ";\0" in the
SREREAD string which obviously cased reparsing to fail

test from http://www.in-ulm.de/~mascheck/various/cmd-subst/
2011-11-22 18:01:41 +00:00
tg d7079f3f0e bump 2011-11-19 21:22:02 +00:00
tg 0220aeeb61 disable cd-pe test on Hurd, it also wrecks havoc with check.pl
https://buildd.debian.org/status/fetch.php?pkg=mksh&arch=hurd-i386&ver=40.2-4&stamp=1321059202
2011-11-19 17:25:55 +00:00
tg e20b1295b7 promote x=(a b); x+=(c) to standard mksh functionality at cost of 932 MKSH_SMALL .text bytes on MirBSD/i386 2011-11-11 22:14:19 +00:00
tg 90afc54ee8 • select(0, …) misbehaves on Interix (by Markus Duft <mduft@gentoo.org>)
• select(n, NULL, NULL, NULL, …) behaves the same (by Bruno Haible)
2011-11-09 22:17:26 +00:00
tg f048ac2f58 disable another symlink-using test on MSYS 2011-11-08 23:10:58 +00:00
tg c620f865c1 cid 1004E0F5C27271F5B00 broke integer-base handling of built-in parameters
mksh -c 'echo a=$RANDOM; RANDOM=0x12; echo b=$RANDOM' # behaviour changed
2011-11-08 22:07:15 +00:00
tg f92108dccc make MSYS match Cygwin more closely; ignore its broken <stdint.h> 2011-11-05 23:39:02 +00:00
tg 92b60a9a5e forgotten in cid 1004EA5BF612F516747 to take '\n' presence as $'…' quoting reason 2011-10-26 20:46:16 +00:00
tg 5893a36bad document “export -” accident found by Snader_LB 2011-10-24 19:41:13 +00:00
tg d6bf9c197b better handling of eval and CPPFLAGS in build system 2011-10-07 19:51:44 +00:00
tg 9782f6b4d1 • access(2) is broken in at least kFreeBSD 9.0 as “modern” OS, so bring
back the wrapper code as well as refactor most other code calling it
• apparently, names can’t end in ‘_’ or contain ‘__’ anywhere…
2011-09-07 15:24:22 +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 5d9c88ceeb jg71 reported -DMKSH_ASSUME_UTF8=* breaks defining stristr 2011-08-27 17:30:07 +00:00
tg 80223417d7 followup fix for 1004D90467358D6B13C regarding escaped substitutions
found in, out of all things, Debian/m68k, by Wouter Verhelst (Yoe)
fix hacked at DebConf 11, Бања Лука, Република Српска, Босна и Херцеговина
2011-07-26 16:57:28 +00:00
tg a7566387cf optimise an if away, and possibly even the function bodies… 2011-07-20 23:47:29 +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 09db3d67a2 finish merging from R40-stable; set version number to yesterday though 2011-07-16 17:08:52 +00:00
tg 620faa3dc9 ‣ merge from mksh R40-stable
drop heredoc-weird-3 while here, it’s not deterministic by design(?)
2011-07-16 17:08:35 +00:00
tg 3f014c8daf utf8opt-3 needs to be split in half, part of it needs-ctty
10x arekm again
2011-07-07 21:02:39 +00:00
tg a4a000eafb take down the entire xterm (or GNU screen tab), hard, with:
mksh-R40 -c 'x=$COLUMNS; awk "BEGIN{exit(1)}"'
10x to the PLD Linux guys for spotting _and_ bisecting this!
2011-07-07 20:24:53 +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 f2405b7dde • bump patchlevel to today’s
• while here, reformat 'struct tbl' comment-wise and placement-wise
  and drop the Tflag typedef
• while here, write regression test for the "global" built-in, which
  does what typeset is supposed to do except that it doubles as "local"
2011-07-05 20:12:20 +00:00
tg 0739fa74a0 address "env RANDOM=1=2=3 mksh" DoS by integrifying more 2011-07-02 17:57:41 +00:00
tg edaab2cafe tabcomplete ~ and ~foo like $FOO (idea by yofuh) 2011-06-30 13:48:13 +00:00
tg 43c8d8765f pretty tricky thing, IBM’s curses library does nameref foo=foo… 2011-06-21 21:50:26 +00:00
tg 7ce3a2ad54 HP-UX aCC suggested more “≠ 0” and parenthesēs 2011-06-12 14:58:45 +00:00
tg 6571d66386 add missing shf_flush() before prompting 2011-06-11 03:14:50 +00:00
tg 5aa22cff70 • fix empty input
• fix input without trailing newline for integer-base-one-3{A,W}r
2011-06-09 21:53:12 +00:00
tg 1fbd3e5ee0 bugfix for when the last line was full 2011-06-09 21:26:21 +00:00
tg 60ccad3dfc check for embedded NULs work 2011-06-09 21:10:50 +00:00
tg e0fb8dc431 • rework hash table interna to avoid gcc-4.1 on Debian etch bug
• also improve behaviour with _a lot_ (>2²⁸) entries
• while here, improve comments and whitespace
2011-06-05 19:58:21 +00:00
tg 92ea9a224f heredoc-weird-3 is timing-critical ⇒ need-pass: no 2011-06-05 16:49:54 +00:00
tg 57b849910f mark all 2×3 history-ed tests as need-pass: no 2011-06-04 17:08:11 +00:00
tg ebb8bed911 fix segfault due to limit of hashtable entries (global variables) discovered by Jb_boin: unlimit to 2^30 minus epsilon 2011-06-04 16:42:31 +00:00
tg b3d38f9cdf better parsing for x=(…) – bug noted by Frank Terbeck 2011-06-04 16:11:20 +00:00
tg 128a2e8fc1 add test for x+=(y z) and ;;& functions in tree dumper (!MKSH_SMALL) 2011-05-29 16:38:58 +00:00
tg d1b8800ee8 • AIX: display OS version better (tested on 5.3 by cnuke@)
• IBM XL C: display version better (tested on V7.0 by cnuke@)
• do not 'IFS=: read nr name', Cygwin 1.7 dash fails it
• disable cd-pe, glob-range-3 on Cygwin (the former cannot
  succeed because the mv fails, the latter fails from 1.7 on)
• mark heredoc-tmpfile-8 as need-pass: no
• apply __attribute__ only to a function prototype, not to
  the body (even if static), since xlC fails that
• bump version to R40 (beta)
2011-05-29 16:31:42 +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 9fe3ba48d2 handle MKSH_SMALL not doing foo+=(…) 2011-05-07 02:02:47 +00:00
tg 40e914e8a5 • fix an inverted logic bug in the test I wrote
• only trigger deleting an alias in favour of a function for “()”, not
  just the opening parenthesis: “stop( )” is not a function definition
  (well, actually it seems to be, but… not according to POSIX, anyway)
• defer dropping the alias until the function is actually defined (õÕ)
2011-05-07 00:51:12 +00:00
tg 88686b81bd a regression and a new bug, found during cvs development 2011-05-07 00:02:26 +00:00
tg 3f21a0e199 • add patch from Robert Luberda <robert@debian.org> fixing the
four-argument form of test (yet again…), thanks
• drop the obsolete (pre-POSIX) form “test -t” without fd
2011-05-06 15:41:25 +00:00
tg c021aa4cad • use a flag for determining here strings, don’t parse delimiter every time
• don’t leak memory parsing possible I/O redirection tokens
• get rid of volatile by using more const (also helps codegen, methinks)
• support empty here document markers (mksh extension)
• pimp the manpage
2011-05-05 00:05:01 +00:00
tg 4345dd1fb8 += support for variables and arrays 2011-05-04 23:16:05 +00:00
tg 69f98bca9a • fix wtf(1) by keeping the paren in ${foo#\(} properly escaped in COMSUB
• merge tputS and wdstrip_internal
⇒ net save: 604 .text 0 .data 0 .bss (MirBSD/i386)
2011-05-02 22:52:54 +00:00
tg 8bc51681b1 sync clog 2011-04-22 21:44:35 +00:00
tg 61a8888213 always catch SIGALRM even in non-interactive shells to make sleep work 2011-04-17 12:24:44 +00:00
tg e39dea490f sync… various things 2011-04-09 18:47:14 +00:00
tg 8c46637835 cnuke says Haiku is like GNU in that it has no /usr whatsoever 2011-04-09 15:39:50 +00:00
tg 7d3643d7b4 skip the UTF-8 BOM early, then check the magic (ELF, a.out, COFF, …) 2011-04-02 10:30:11 +00:00
tg a7091123aa Add “-C regress:no-ctty” option to test.sh for Fedora chroots
STRONGLY DISCOURAGED
2011-03-28 21:58:06 +00:00
tg b91b037e6a we got a decision on pathnames with exactly two leading slashes
thanks, Eric and David!
2011-03-28 21:31:01 +00:00
tg 6fddfc009b I made a mistake in the tests; this stuff works always (and can be tested)
but triggers only for /bin/sh if MKSH_BINSHREDUCED (otherwise needs -o sh)
2011-03-28 21:18:00 +00:00
tg 19e128c4e1 add testcases, bump vsn 2011-03-28 08:40:42 +00:00
tg e8ea9954aa • Implement http://austingroupbugs.net/view.php?id=367 and align things
a bit more with POSIX and the other shells

I considered http://austingroupbugs.net/view.php?id=253 but the use
of bi_errorf() is interesting, especially as it’s often enough a
noreturn function, and funnily enough, 'cd -P /foo' returns 0 while
'chdir -P /foo' fails (so idk where to put -e)…
2011-03-27 18:50:06 +00:00
tg 5f31b8c97a • bring back test -H ifdef S_ISCDF (for HP-UX)
• whitespace, etc.
• bump version for tonight, I’m not gonna hack on c_cd,
  all this pathname stuff is mind-boggling…
2011-03-26 21:46:06 +00:00
tg a55de5f840 • rewrite simplify_path() to keep more in line with do_realpath()
• add regression test to ensure that //foo pathnames are never simplified
2011-03-26 21:09:09 +00:00
tg 79862cc1f4 one more from Austin ML 2011-03-26 16:19:29 +00:00
tg 84f7055f8f special-case another bizarre POSIX corner case
after david korn agreed to change ksh93 to match
2011-03-26 16:11:43 +00:00
tg 2dffc771ac new (some possible) testcases from Austin ML, and one fix 2011-03-26 15:32:37 +00:00
tg 8d8ee0cc6a ironhead reported in IRC that some Cygwin guys (not he, he’s just the
packager) complain that mksh collapses two leading slashes; IIRC POSIX
has a clause for UNC pathnames, so stop doing that, plus add a test
2011-03-23 18:47:07 +00:00
tg bc4c3b9af0 • save/restore here document pointer during yyrecursive(), fixes crash
• add mirbsd/openbsd (omalloc rules!) specific testcase for the above
• $__progname must be used quoted, fix in comsub-torture testcase (my bad)
2011-03-21 21:57:35 +00:00
tg 3c41d2b063 fix cast; bump version 2011-03-17 22:09:23 +00:00
tg 5239e8ea4c actually, we need the android lsmod to be a builtin not an alias… 2011-03-16 20:56:33 +00:00
tg 79c6d6043e • introduce a virtual TARGET_OS=Android that just sets a check category
and switches to the TARGET_OS=Linux
• introduce android as regression test suite category
• add an android specific standard alias
• clean up redundant ‘-o sh’ arg in a few checks
2011-03-16 20:26:36 +00:00
tg fd0d60b71b testsuite for mksh-small needs adjusting 2011-03-13 17:07:08 +00:00
tg 4e7d9bdb33 we need not only store into the retrace buffers recursively but also ungetsc 2011-03-13 16:20:45 +00:00
tg af53a7d16a • speed optimisation: drop SF_FIRST flag, factor out skipping the
UTF-8 BOM instead (UTFMODE has a separate value now for activated
  during BOM skipping)
• parsing a COMSUB now skips UTF-8 BOM, too, but only temporarily
2011-03-13 16:03:54 +00:00
tg e66eaab861 let SLETARRAY use SRETRACE, too 2011-03-13 15:57:23 +00:00
tg 2a3d4db123 lint is your friend 2011-03-13 01:20:25 +00:00
tg a3c79ad771 now fix that segfault and other bug from yesternight
do it like ksh93 though, not like bash and zsh
2011-03-12 23:06:43 +00:00
tg 75db4cdb56 • back out the EXPRSUB change
• optimise some code
• split testcase into two, one with expected-fail
2011-03-12 23:04:48 +00:00
tg fb1392fb6b even more test cases for comsub (2 breaking, but one of them fixed already) 2011-03-12 20:20:17 +00:00
tg 97e1987dbf tests for a segfault and a failure-to-fail from “Jb boin on dedior” on IRC 2011-03-12 01:04:39 +00:00
tg f8659785ac • add a tree debugging dumper #ifdef DEBUG
• use shf_putc (macro), shf_putchar (function) ipv tputc
• replace shf_putchar(x,y) calls for side-effect-less x with shf_putc
• plug another bug in the tree code – '\' → "\\" (backslashes must be
  escaped inside double quotes, too)
• adjust testsuite (and, I _had_ wondered…)
2011-03-08 18:49:51 +00:00
tg 6894618bb9 • x=$(cat <<-EOF
EOF) # works again now, plugging a regression
• rewrite the here document parsing code to be *much* more efficient
  (and a bit more readable too!) using goto, while here (no kidding)
2011-03-07 20:32:50 +00:00
tg 1f392ab09b • more fixes (some regression, some new)
• more testcases, stricter testcases
2011-03-06 17:08:14 +00:00
tg 469da2e5e4 drop IFS-space-colon-3 because dash is the only shell which passes it,
but ksh93 passes ifs.sh which I assume is more correct, and mksh and
ksh93 have the same result for this (as do bash2/4, posh; zsh differs)
2011-03-06 17:06:17 +00:00
tg c995f7ca98 I thought of making COMSUB pass a pointer to the struct op *t->left around
instead, but the parser for the so-called “backticks” (U+0060) still emits
plaintext COMSUB wdstrings, and the evaluation code emits plaintext if the
code is not run (‘-n’ option), so it’s not worth the effort and memory ma-
nagement issues, even though it _would_ optimise the most common case…

Bump version numbers, sync regression tests; add one testcase from the old
webpages too. Sync manpage, this now works, but keep the workaround in, as
“portability issue” with slightly changed wording.

Also, /bin/sleep must be used in one manpage example if sleep is built in.
2011-03-06 01:50:11 +00:00
tg ad2fd952e4 nvm, got it 2011-02-27 19:41:17 +00:00
tg 3019066e60 no idea why MiNT has this… issue… 2011-02-27 19:31:34 +00:00
tg e0c4ad7fa9 port to FreeMiNT: add OS uname and flags; 2>&- is evil™; $UNIXMODE must be preserved; unlink(2) is weird 2011-02-27 19:29:20 +00:00
tg 816bf86710 MKSH_NOPROSPECTOFWORK has no co-processes. at all. 2011-02-19 21:39:14 +00:00
tg 0b57abd4d3 • add -u option (POSIX: unbuffered ⇒ nop) to the built-in cat
• PIPESTATUS now supported (like bash 2) whose last member
  may actually differ from $? since the latter may not be the
  result of a pipeline partial command
• add regression tests, documentation, etc.
2011-02-18 22:26:13 +00:00
tg 36d41ed9ee * plug a regression introduced as a pasto (think, mira!)
* add selftest-direct-builtin-call regression test, while here
2011-02-13 21:13:08 +00:00
tg a796512040 • more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
  variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
  work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
  variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
  bin/echo bin/kill bin/pwd bin/sleep (exact matches)
  bin/test bin/[ (were scripts before)
  bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 01:18:23 +00:00
tg 5161342b9b fix warning about signed vs. unsigned comparision and potential truncation error 2011-02-09 13:08:27 +00:00
tg d4658a569e refactor code to be able to track whether we have a parameter substitution
or a “proper” glob expansion; if there’s a dollar, but not a glob, refrain
from appending a space later (LP: #710539)
2011-02-03 15:57:52 +00:00
tg d7c2e16ca0 fix typos 2011-01-30 02:18:25 +00:00
tg 30d8e3934d SUSv4 says trap foo UNKNOWN is not a syntax error, merely exit ≠0.
Inspired by 673dab8698b0399c967216c02262eaf95361a75c.
2011-01-30 01:36:00 +00:00
tg bdfcdc56c8 introduce MKSH_NOPROSPECTOFWORK which is like pdksh’s JOB_SIGS in reverse, like MKSH_UNEMPLOYED is pdksh’s JOBS in reverse; allows mksh to work (hah! no pun intended…) with klibc (and possibly, Syllable Desktop and Plan 9) for now, until they fix their bugs 2011-01-30 01:35:35 +00:00
tg 414c09ab1a plug regression introduced with read -d by fixing the problem differently 2011-01-22 20:33:14 +00:00
tg da9d0f3d97 ${foo@x} is now special-expansion for values of x, defined for now:
‘#’ = hash of $foo
2011-01-21 22:25:34 +00:00
tg 846fbde3b8 add read with delimiter, like AT&T ksh93 (thanks Dave for the suggestion) 2011-01-21 22:00:17 +00:00
tg 230f59d064 New functionality: assign here document to string variable directly,
without cat and temp files. Hacked in Lëtzebuerg ☺

This was the third try. Where to put this was not palpable… same for =(…)
2011-01-09 21:57:29 +00:00
tg b4948e430f this is a bashism but might be from ksh93 IIRC… still dead ugly as hell! 2010-12-19 20:00:56 +00:00
tg 27dce9168a change behaviour of argument-less exit in traps to match SUSv4; Debian #599484 (original patch from Jonathan Nieder, thanks!) in a variant that appears to handle nested traps well 2010-11-01 17:29:05 +00:00
tg 3365cb8d0f • Build.sh: fix a compiler warning which, had it not been irrelevant in
a mirtoconf check, would’ve been a real problem on an LP64 platform
• sh.h: work around a bad interaction between -Wformat on gcc and manual
  string pooling for T_synerr, which is used in place of a format string
  in some places
2010-10-01 19:04:38 +00:00
tg e169648b89 while here, change SETUID_CAN_FAIL_WITH_EAGAIN to abort immediately
by suggestion of Chris Palmer again
2010-09-19 19:28:23 +00:00
tg 915b30adfe revert part of the “size reduction” diff (zero size change though):
shellf() implies an shf_flush()…
2010-09-15 21:08:19 +00:00
tg 667d792d6a • Address concerns of Chris Palmer from the Android security team
– possible integer overflows in memory allocation, mostly
    ‣ multiplication: all are checked now
    ‣ addition: reviewed them, most were “proven” or guessed to be
      “almost” impossible to run over (e.g. when we have a string
      whose length is taken it is assumed that the length will be
      more than only a few bytes below SIZE_MAX, since code and
      stack have to fit); some are checked now (e.g. when one of
      the summands is an off_t); most of the unchecked ones are
      annotated now
    ⇒ cost (MirBSD/i386 static): +76 .text
    ⇒ cost (Debian sid/i386): +779 .text  -4 .data
  – on Linux targets, setuid() setresuid() setresgid() can fail
    with EAGAIN; check for that and, if so, warn once and retry
    infinitely (other targets to be added later once we know that
    they are “insane”)
    ⇒ cost (Debian sid/i386): +192 .text (includes .rodata)
• setmode.c: Do overflow checking for realloc() too; switch back
  from calloc() to a checked malloc() for simplification while there
• define -DIN_MKSH and let setmode.c look a tad nicer while here
2010-09-14 21:26:19 +00:00
tg 56a69907d5 optimise error messages, option parsing, and make more builtins
recognise "--", costs us 20 .text 0 .data 0 .bss
2010-09-05 19:51:35 +00:00
tg 06c6be0a70 shave off another 468 bytes: we’re 300 bytes smaller than BEFORE the
cat builtin was added now… (also removed utf-8 from source files, in
favour of just ASCII)
2010-08-28 20:22:24 +00:00
tg d09fd67299 make cat an mksh builtin, for things like here documents
if any options are given, the external programme is invoked instead
2010-08-28 17:21:46 +00:00
tg 1924f91aad this is 「category: os:mirbsd」 because of hardcoded errno and strerror values 2010-08-24 15:47:44 +00:00
tg 7fdc42cead fix realpath builtin’s handling of (source) pathnames with a trailing slash
as per POSIX (if a trailing slash is part of the symlink target it fails as
well, like GNU readlink -f does)
2010-08-24 14:42:04 +00:00
tg c187f3089f a tad annoying, when external programmes such as GNU screen are running,
we don’t get SIGWINCH when the window size changes during the runtime of
that, so, the signal is only usable reliably during editing in the shell
and we re-check the window size before each interactive edit line again
2010-07-25 11:35:43 +00:00
tg befbed2859 int → bool 2010-07-24 17:08:30 +00:00
tg c11d35312a Michal Hlavinka from Red Hat found another SIGSEGV
fix: when iterating over all Sources, know when to stop…
2010-07-21 11:31:16 +00:00
tg c6eedad976 *sigh* this code is interesting: assume you want to output via shf to
a string buffer whose window size is currently 32 (initial), your data
is 96 bytes, this routine used to resize the buffer to 64, append your
first 64 bytes to it (no matter if there's already something in it)
and then writes the remaining bytes to stdio fd instead of the string…
if it doesn’t SIGABRT before

discovered by wbx@ – thanks – bug inherited from pdksh 5.2.14 (AD 1999)
2010-07-19 22:41:04 +00:00
tg 7c91e018f4 • merge printf from OpenBSD
• deactivate %a and %A since our libc doesn’t have it
• rewrite the mksh integration code to use shf instead of stdio, removing
  floating point support always in the process, as shf doesn’t support it
  ⇒ saves 11114 (6706 text, 168 data, 4240 bss) with dietlibc on Debian
• fix -Wall -Wextra -Wformat -Wstrict-aliasing=2 for gcc (Debian 4.4.4-7)
• fix these and -Wc++-compat for gcc version 4.6.0 20100711 (experimental)
  [trunk revision 162057] (Debian 20100711-1) except:
  – a few enum warnings that relate to eglibc’s {g,s}etrlimit() functions
    taking an enum instead of an int because they’re too stupid to adhere
    to POSIX interfaces they design by themselves
  – all “request for implicit conversion” involving a "void *" on one side
• tweak the manual page somewhat more
2010-07-17 22:09:40 +00:00
tg 6b006202a1 partial oksh sync (RCSID and do add some parenthesēs to the list of
reserved words, but really only these which are only recognised at
the beginning of a line as the context says, not blindly all of them)
2010-07-13 13:12:32 +00:00
tg a6c81ea978 on obsd/mbsd, entropy is cheap enough for us to do this (codepath in
kernel checked for both) for additional seeding ($RANDOM is still from
the LCG only)
2010-07-11 11:17:33 +00:00
tg 30046ffcf2 implement “live” SIGWINCH handling in the Emacs editing mode
for winstonw from IRC #!/bin/mksh
2010-07-04 17:45:17 +00:00
tg 747b27a846 apply diff from manuel giraud via oksh to keep track of LINENO in a trap 2010-05-22 12:49:16 +00:00
tg 549c510269 related to 1004BF041CB522EEEE3 ${foo[*]} is a vector too; add testcases 2010-05-16 19:17:42 +00:00
tg f24e2c80a9 disallow some more kinds to trim a vector; Debian #581867 2010-05-16 19:04:42 +00:00
tg 01a0d1104a address two performance issues in do_realpath():
• avoid calling realloc twice in sequence, since the final
  size is known at the first call already
• do not lstat(2) the same path twice in the Hurd codepath
2010-04-27 21:39:09 +00:00
tg 6e98fbe27b Fourth time’s a charm… another bugfix related to the commitids
1004BBDD84556472D84, 1004BBF77B81D30DA7C and 1004BBF7CD656308A1C
to unbreak kwalletcli
2010-04-20 09:10:07 +00:00
tg 14ea7e9038 draft a testcase to understand the problem fixed by cid 1004BBF77B81D30DA7C
and make it actually work: the OpenBSD fix failed since 1004BBDD84556472D84
2010-04-09 19:16:31 +00:00
tg b2d317986d more tests (from Herbert Xu) and answers (from Geoff Clare) 2010-04-09 14:46:43 +00:00
tg ff9f89f22f Fix two more POSIX conformance bugs and minor documentation/comment issues 2010-04-08 13:21:08 +00:00
tg 401e262689 fix another expand-ugly SUSv4 bug 2010-03-27 16:53:17 +00:00
tg 2bb0ddb80d let’s just add more test cases
from Message-ID: <309618f38393fa1d57b69a67f1a6ce02@austingroupbugs.net>
2010-03-18 19:45:39 +00:00
tg 05fe209521 correct #39 (but leave #38 as-is and hope POSIX gets fixed instead)
cf. Message-ID: <20100316102753.GB26711@squonk.masqnet>
2010-03-16 21:32:47 +00:00
tg 50f081c369 even better on Haiku:
* let ulimits work
* add a Haiku-specific ulimit
* always use UTF-8, they have no locales but a UTF-8 terminal
2010-03-14 11:58:33 +00:00
tg 251189868d another test (#39 is up for discussion on austin-group-l still) 2010-03-01 17:28:05 +00:00
tg e5e6857c43 (hopefully) fix the substitution thing for good 2010-02-25 20:18:19 +00:00
tg 3ba694a00d more/improved test cases
• expand-unglob-{dblq,unq} are the same as dash, but with ‘\}’ → ‘}’ as
  per austin-group-l discussion, although this is not (yet) a standards
  requirement, just a “doesn’t make sense otherwise” thing
expand-ugly:
• printf '%s\n' "foo ${IFS+"b   c"} baz" → no field splitting, ksh93 is
  wrong here (§2.6.2)
• ‘\}’ vs. ‘}’ as above
• ksh93 dropping a ‘}’ is probably another ksh93 bug
2010-02-25 11:47:33 +00:00
tg ae2901146f begin fixing up ${foo+word}, see austin-group-l for discussion and DR 2010-02-23 21:51:49 +00:00
tg 150a35a02d x_bind cannot have the nonnull attribute
cought by Frank “enstein” Terbeck «ft:#grml» (efftee), 10x
2010-02-23 18:13:04 +00:00
tg 5beee95d6b at least _parse_ the construct ${foo+(bar)} correctly
(whether the output is correct is still up for debate)
2010-02-18 17:31:23 +00:00
tg 0d1083fc9c this exclusion is unwarranted 2010-02-18 17:30:19 +00:00
tg 4eb17f8752 remove some more of this ugliness 2010-01-29 09:34:31 +00:00
tg c67bed8790 • unbreak testsuite for MKSH_SMALL
• sync version and © year
2010-01-28 20:58:34 +00:00
tg 0c94277ccb To solve the incompatibility issues between mksh-current, old mksh versions
and vendor pdksh versions, re-introduce FPOSIX alongside FSH. The semantics
are now:
‣ set -o posix ⇒
  • disable brace expansion and FSH when triggered
  • use Debian Policy 10.4 compliant non-XSI “echo” builtin
  • do not keep file descriptors > 2 to ksh
‣ set -o sh ⇒
  • set automatically #ifdef MKSH_BINSHREDUCED
  • disable brace expansion and FPOSIX when triggered
  • use Debian Policy 10.4 compliant non-XSI “echo” builtin
  • do not keep file descriptors > 2 to ksh
  • trigger MKSH_MIDNIGHTBSD01ASH_COMPAT mode if compiled in
  • make “set -- $(getopt ab:c "$@")” construct work

Note that the set/getopt one used to behave POSIXly only with FSH or
FPOSIX (depending on the mksh version) set and Bourne-ish with it not
set, so this changes default mksh behaviour to POSIX!
2010-01-28 15:18:51 +00:00
tg 2e9654ffa4 introduce “typeset -i foo[*]”, rationale see cid 1004B5DA60A56BFB604 2010-01-25 14:25:16 +00:00
tg c700693d11 Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.

This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
tg 833810a154 While we were supposed to use Ctrl-Arrowkey for wordwise jumping,
some idiotic terminal emulators and/or people seem to use the es-
cape codes normally denoting Alt-Arrowkey instead so let's simply
bind them to the vt_hack as well... (untested)
2010-01-08 22:21:06 +00:00
tg df4137c2e2 I don't care that AT&T ksh93 fails this nameref test case, but
it's important and we'll want it.
2010-01-04 21:08:00 +00:00
tg 0611ecad1f make [[ -o ‣-U ]] = [[ -o ‣+U ]] = [[ -o ‣utf8-mode ]]
where ‘‣’ is either nothing, ‘!’ or ‘?’ as usual.
2010-01-01 18:02:01 +00:00
tg 6115f5a91c • re-implement wcswidth-like behaviour for ${%foo} even in !UTFMODE
• merge the rest of branch tg-wcswidth-behaviour
• enhance test cases for wcswidth-like behaviour
• switch hash table collision resolution algorithm to Python’s as announced
• bump vsn
2010-01-01 17:44:10 +00:00
tg c413edb34a jobs.c: apply patch from deraadt@o:
│remember to restore errno (ie. stop someone from making a mistake later)
│ok guenther
check.t, sh.h: bump vsn

I wonder though why errno must be restored even if nothing was
called after reading it… moid?
2009-12-31 14:05:44 +00:00
tg 769e222586 re-vamp __attribute__ handling; let this pass on HP-UX bundled compiler
as well as HP aCC
2009-12-12 22:27:10 +00:00
tg 8213a28403 llvm/clang scan-build is now content… 2009-12-05 17:43:50 +00:00
tg 417fd60c76 * fix 'set -A foo -- [2]=a b c' contingency (tested against GNU bash4,
which, in its latest sid incarnation, even received mksh's ability
  to produce ${!foo[*]} array keys, wow!)
* plug a memory leak while here (ATEMP only, but still)
2009-12-01 19:15:35 +00:00
tg fa3acb939b fix 'mksh -U -i' and 'mksh +U -i' 2009-11-28 15:38:30 +00:00
tg a09f05e77a /me is annoyed
I read, IIRC in the Cederqvist, that 'cvs tag' sets a sticky tag onto
the cwd… it doesn’t, apparently. (I actually like it better this way,
but one needs to know!)
2009-11-28 14:28:03 +00:00
tg 883d9d99b3 switch ${%foo} to wcswidth-like behaviour – slightly problematic, and
the “set +U” case isn’t even handled

committed to branch because I’d like to get more input on this, for now
2009-11-28 14:21:47 +00:00
tg 4cff10296b bump vsn 2009-11-22 14:25:18 +00:00
tg e240e62a55 don't tell lies 2009-11-22 14:13:38 +00:00
tg 2094e3f25c since we have wcwidth anyway, expose it as ${%strvar} to the user, iff
utf8-mode is enabled (otherwise it'll be a synonym for ${#strvar} aka
the number of octets in it)
2009-11-21 23:23:20 +00:00
tg 398b5b7a60 fix that as well 2009-11-21 22:32:08 +00:00
tg 6e67920bef improve globbing:
• a=blöd; print ${a%???} → now printf 'b' not 'bl' in UTF-8 mode
• a=hä; print ${a%?} still broken
2009-11-21 22:30:36 +00:00
tg d02e6be6cf bugfix: ${x#?} should expand to nothing not '' if x was unset 2009-11-21 22:29:12 +00:00
tg fe853065bb make print_columns() aware that octets≠characters≠columns 2009-11-09 23:35:11 +00:00
tg 6fcacf577d make tab completing filenames with ':' '=' '$' '`' work as well as
others (colon and equals sign need to be simply escaped, while dollar
sign and accent gravis need double escaping like opening square brak-
ket did back then); add = to C_QUOTE to simplify (doesn't break any-
thing) and sort these strings asciibetically while here
2009-10-30 00:57:39 +00:00
tg dc98ec23a6 do not use PATH_MAX on GNU/Hurd (even if it *was* defined), but use
some glibc-only functions that don’t require its use instead

tested on gnubber, where (admittedly) sysconf(_PC_PATH_MAX) == 1024…
2009-10-27 17:00:02 +00:00
tg ceb591bf6a • better IV for the oaathash-on-binary (as if we prepended a '\x01')
• better variable name for the LCG state
2009-10-18 12:30:06 +00:00
tg eafe88aa74 • overhaul handling of special variables
• use a combination of the one-at-a-time hash and an LCG for handling
  the $RANDOM special if !HAVE_ARC4RANDOM instead of rand(3)/srand(3)
  and get rid of time(3) usage to reduce import footprint
• raise entropy state (mostly in the !HAVE_ARC4RANDOM case though…)
• simplify handling of the $RANDOM_SPECIAL generally
• tweak hash() to save a temp var for non-optimising compilers
• some int → mksh_ari_t and other type fixes
• general tweaking of code and comments
2009-10-17 21:16:05 +00:00
tg 578d4e6314 fix exit-eval-1 (Debian #550717), sync SUSv4 wording, improve comments 2009-10-15 16:36:27 +00:00
tg c7a8b367f8 remove regression-44 in favour of utilities-getopts-1 (the former checked
the AT&T ksh88 behaviour, the latter the AT&T ksh93 behaviour, which dif-
fer from each other, on the very same thing with the exact same test)
2009-10-15 16:32:23 +00:00
tg 0d1ef736c7 modify the oksh-varfunction regression test to reflect that, indeed, a
change of a variable inside a Bourne style POSIX function will affect
the current execution environment of the function caller (to be consi-
stent with exec-function-environment-1)
2009-10-15 16:24:49 +00:00
tg 7b8f207cc9 new exec-function-environment-1 replacing exec-simple-1 from posh, after
reading SUSv4 throughoutly
cf. Message-ID: <Pine.BSM.4.64L.0910151542460.4645@herc.mirbsd.org>
2009-10-15 16:15:03 +00:00
tg ce7359ffc5 posh’s utilities-echo-2 is actually incorrect; reason here
cf. Message-ID: <Pine.BSM.4.64L.0910151525270.4645@herc.mirbsd.org>
2009-10-15 15:32:34 +00:00
tg a9ca7a04c8 add two regression tests from Debian posh, adjusted to pass with ksh93 2009-10-15 15:23:41 +00:00
tg 25516ac756 another exit code in substitution questionable thing
split this one by set ±o sh
2009-10-15 14:58:51 +00:00
tg 84f8d3191a make some of these tests more posh-friendly 2009-10-15 14:12:46 +00:00
tg 620b4446d7 make exit-eval-1 an expected-fail for now, until we can fix this 2009-10-15 12:50:11 +00:00
tg b694bde402 rename regression-56 into exit-eval-1 and change expected output
from what AT&T ksh88 does to what AT&T ksh93 does and POSuX expects

Reported by Clint Adams as Debian #550717, to be fixed...
2009-10-14 18:06:57 +00:00
tg 888c7befea group exit-related tests 2009-10-14 18:04:52 +00:00
tg 549888a183 while testing haserl-0.9.26 on MirBSD, I discovered that the echo builtin
in FSH mode did in fact, contrary to POSIX and Debian Policy 10.4 behavi-
our (I think), interpret escape sequences; fix and add testsuite for echo
2009-10-10 21:17:31 +00:00
tg b4a32ff5f7 cygwin seems to force a+x for files beginning with ':\n' so prepend
a nop newline to make mksh.exe pass this test
2009-10-10 17:39:48 +00:00
tg 73147a7fe9 fix lazy evaluation of assignments in ternary ops 2009-10-04 13:19:33 +00:00
tg 5f58261287 fix long-standing parenthesēs problem: ((foo) || bar) is now parsed corr. 2009-10-04 12:45:23 +00:00
tg c2e5737fca fix dollar quotes in here strings and here documents (regression) 2009-10-04 12:44:19 +00:00
tg 40d11a2066 on the other hand, this is a regression in mksh, apparently 2009-10-04 03:13:06 +00:00
tg 33b9f8b666 * rename "set -o posix" (FPOSIX) to "set -o sh" (FSH) because it's not
just a "somewhat more POSIX" but also a "/bin/sh legacy kludge" mode
* consistently capitalise POSIX and SUSv3/SUSv4 (same as AT&T ksh) and
  Bourne shell
2009-10-02 18:08:37 +00:00
tg 2ea131ab1f make another Debian posh bug into a regression test (expected-fail) 2009-10-02 17:05:01 +00:00
tg c0589fd329 fix typos, From: Clint Adams <schizo@debian.org> 2009-10-02 16:59:53 +00:00
tg ff8b75f46f SUSv4 says that there be exit 127; the old code tried but failed, so it
was an actual programmatical bug…
2009-09-29 12:28:13 +00:00
tg a59d14b565 further optimise and simplify the handling of $RANDOM, reads and writes
to it are now either arc4random or rand/srand, but srand retains the old
state; set +o arc4random is no longer possible, but if it's there we use
arc4random(3), if not, we use rand(3) for $RANDOM reads; optimise special
variable handling too and fix a few consts and other minor things
2009-09-26 03:40:03 +00:00
tg 1dfb13b603 change undef/def MKSH_NOVI into 0/1 MKSH_S_NOVI flag (with more to come:
MKSH_S_EDIT for small (Emacs) editing mode, MKSH_S_FEAT for all the dis-
abled language features), which can be set to 0 despite MKSH_SMALL being
defined to re-enable the Vi command line editing mode (which I wouldn't,
but fits into the general mastermind scheme)
2009-09-24 17:15:33 +00:00
tg 1a28786229 * shrink MKSH_SMALL even further by removing functionality like
some GNU bash extensions (suggested by cnuke@) and bind macros
* make the random cache more efficient (and the code potentially
  smaller, although we have a new implementation of the oaat hash
  function, alongside the old one, now) and pushb only if needed
  (i.e. state has changed or user has set $RANDOM, but not onfork)
2009-09-23 18:04:58 +00:00
tg 1ea1096a4e Add a hack input function for VT100-style key sequences; support
Ctrl-CurLeft and Ctrl-CurRight (not quite ANSI, but fits the scheme)
2009-09-20 17:23:52 +00:00
tg 9fd4b9db41 $'…' functionality, documentation improvements, fixes for backslash
expansion in all modes, regression tests for both kinds of backslash
expansion; unbksl() revamp; make CTRL macro available globally
2009-09-19 21:54:46 +00:00
tg 7806fe510a allow “function stop () {” (bashism, an evil one) 2009-09-19 18:36:59 +00:00
tg 3639137e48 another ksh93 feature: test -o ?foo (almost zero cost) 2009-09-07 17:24:49 +00:00
tg 9dd98da40d Support Dave Korn’s alternative 「'a'」 (or 「'…'」) form for base-one
integers in addition to my 「1#a」 (or 「1#…」), which also allows for
finer end-of-character checking. Note that this is locale-dependent in
ksh93, set ±U dependent in mksh, and mksh’s OPTU-16 encoding is used.
2009-09-06 17:55:55 +00:00
tg 9531e12b36 merge the nameref code, using mksh standard scoping as discussed 2009-09-06 17:42:15 +00:00
tg 4a4be7d313 add the chdir builtin from mircvs://contrib/hosted/tg/deb/mksh/ for
better dash compatibility (mksh is now a dash superset if printf is
compiled in)
2009-08-30 21:02:01 +00:00
tg 09abc55150 documentation and test suite for tonight’s new features, ☾ gn8 2009-08-28 22:46:21 +00:00
tg dc976e5923 spotted a missing substitute() call inside evaluate() call
incl. regression test
2009-08-28 21:35:43 +00:00
tg 0e1266ef90 While mksh R39 builds fine on MirOS #7s8E on my trusty sparc, pgcc 2.95.3
throws out quite some warnings – fix most of them except most emitted via
-Wconversion; work around some others; discard bogus warnings.

sync clog
2009-08-08 13:08:53 +00:00
tg cc4af7b17e some bit of advice 2009-08-01 21:57:52 +00:00
tg c172cdc922 bump version and rebuild+check on MirBSD 2009-08-01 14:21:30 +00:00
tg cb2fd22c38 "official" but unsupported printf-as-builtin code, cleaner API than
in the branch; USE_PRINTF_BUILTIN=1 to enable it (Build.sh + Makefile)
2009-07-30 19:11:12 +00:00
tg 758dc5c6fe * improve CPPFLAGS vs #define handling again: do not touch CPPFLAGS from
Build.sh but use 'if defined(PRECOND) && !defined(TOBEDEFINED)'if possible
* for all of the source code, drop annotations "imake style" (if we check
  for specific OSes, bad, instead of using mirtoconf checks proper) and
  "conditions correct?" (if I'm not entirely sure if that #if catches all
  cases and no false positives) where I can see it by grepping immediately
* bump mksh patchlevel
* refresh Makefiles
2009-07-25 21:31:27 +00:00
tg cfe6688a36 in an interesting piece of self humour, remove the stop and suspend
aliases from shells requiring the Arbeitsamt to get a job ;-)
2009-07-25 20:52:41 +00:00
tg 45cac320e0 sync more tests with GNU bash2 (MirPorts), bash3 (sid), bash4 (experimental) 2009-07-19 11:14:28 +00:00
tg 0ce8f6fa39 bash4 expands 「echo ~/foo」 even if the ~ is generated by a substitution;
add appropriate quotes and mention that bash_4.0-3 (experimental) succeeds
2009-07-19 11:03:18 +00:00
tg b42582689f ABI bump to R39: adhere to the future POSIX standard regarding -o nounset;
add appropriate regression test (except $_ *is* unset in non-interactive
shells). See the thread at:
http://article.gmane.org/gmane.os.miros.general/8863
2009-07-16 15:06:45 +00:00
tg f349aeab3c be more robust against things like Debian #535970
reverts and rewrites the code from cid 10047C1EBA57E4F4AF0

XXX find out if this is done right
2009-07-06 15:06:25 +00:00
tg 3ba2780eb3 another fix from oksh for Vi Mode word erase handling, appears to unbreak
more from cid 1004A2D72DD5A4E4B4F tried to be fixed in 1004A300A72701188E3
but I’d appreciate someone who actually uses Vi Mode to test it:

   Revision 1.26: [7]download - view: [8]text, [9]markup, [10]annotated - [11]select for diffs
   Mon Jun 29 22:50:19 2009 UTC (5 days, 14 hours ago) by martynas
   Branches: [12]MAIN
   CVS tags: [13]OPENBSD_4_6_BASE, [14]OPENBSD_4_6, [15]HEAD
   Diff to: previous 1.25: [16]preferred, [17]coloured
   Changes since revision 1.25: +10 -5 lines
make VSEARCH werase act like regular werase after the last change.
vi back-words and emacs kill-region are not completely the same.
ok merdely@, millert@.  "Get it in" Darrin Chandler
2009-07-05 13:56:48 +00:00
tg e1d8d7ed01 capitalise AT&T® 2009-06-11 12:42:21 +00:00
tg 39bb71fc54 Save another couple of bytes in the !ulimit case 2009-06-10 18:11:27 +00:00
tg 571546c562 • Check if killpg(3) is available; if not, use kill(2) with negative
process ID and hope it works (is POSIXly killpg-endowed)
• bump version
• sync clog
2009-06-08 20:34:40 +00:00
tg 548a415fa9 these are expected failures if -DMKSH_ASSUME_UTF8=0 that cannot be
expressed as check.pl categories
2009-06-07 22:43:46 +00:00
tg 848e237b76 new feature: -DMKSH_ASSUME_UTF8=0 assumes utf-8 is *not* set and skips
environment inspection; useful for initrd and the likes
2009-06-07 22:28:05 +00:00
tg 1794287528 fix event-subst-* regression tests on Cygwin, which insists on a shebang 2009-06-06 14:23:17 +00:00
tg 16c47bbe91 fix bug exhibited by t0000-basic.sh introduced in R38 shortly before the
release: sometimes, a “cd -P” would cause memory corruption because lalloc
internal data was overwritten due to accidentally losing a “continue;”
2009-05-31 15:10:07 +00:00
tg da5dc48cd0 implement an extension that an interactive mode input line, when
starting with an ‘!’ exclamation mark at the beginning of a com-
mand (PS1 not PS2), shall have the same effect as the predefined
“r” alias, to be compatible with csh and GNU bash’s “!string” to
«Execute last used command starting with string» – documentation
and feature request provided by wbx@ (Waldemar Brodkorb)
2009-05-27 19:52:38 +00:00
tg b90007d784 • Build.sh, strlcpy.c: gcc-current conversion &c. warnings cleanup
• histrap.c, lex.c, misc.c: get average stack frame size to <= 768 bytes
• check.t, sh.h: bump version
2009-05-27 09:58:24 +00:00
tg 9179c10119 pgas mentioned ksh93 does [[ $foo ]] (ipv forced [[ -n $foo ]])
and it actually REDUCES code size to allow it as well; mention
in the manpage that it’s merely unportable (and of course exe-
cution time differs); sync clog
2009-05-21 14:28:35 +00:00
tg ae8d54284a commit Syllable-related improvement: simplify p_time 2009-05-20 10:10:02 +00:00
tg b6ce748064 • remove “#if 0” and “#ifdef notdef” style old debugging code
• expose “#ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT” just in case they decide to
  require it and show it in the ksh version automatically
• sync the use of non-ASCII characters over files (unification)
2009-05-16 18:40:09 +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 7641ea6d07 optimise the “regression test” ☺ 2009-05-16 16:03:41 +00:00
tg cc783807d3 this began as a one-word change to the spec (manpage): that
${foo:1:2} operates on characters ipv bytes – which means:
‣ set +U: octets
‣ set -U: MirOS OPTU-8 characters

for consistency I also adapted ${#stringname} to deliver the
length in characters ipv bytes; more may follow; for example
I’d like a way to expose the string width.

you can already get the MirOS OPTU-16 of a character in the
WTF-8 (「set -U」) mode with something like
│ typeset -Uui16 -Z7 x=1#${stringname:position:1}
which will correctly use the PUA EF80‥EFFF mapping for octets.

due to this being an incompatible change, bump to R38

also change the unicode-hexdump sample regression test and
add two news for ${x:1:2} and ${#x} checks in A/W mode ☺
2009-05-16 15:53:02 +00:00
tg 747cc12184 Add search-history-up and search-history-down keybindings (both unbound
by default) to the Emacs command line editing mode; patch originally by
James Butler <sweetnavelorange@gmail.com> but slightly modified

10x
2009-05-16 14:19:23 +00:00
tg 4cd9361b1b amend regression tests with expected-fail COMSUB parse bug 2009-04-22 16:43:18 +00:00
tg 31c96f9d9d make UTF related regression tests more clear 2009-04-08 18:00:53 +00:00
tg 8cc7fdb834 "evil" workaround to the alignment issues: embed an ALLOC_ITEM into
struct env (other structures defined have no "foreign type with pos-
sible alignment constraints" members) and take care of it while dea-
ling in a struct env instance
2009-04-07 19:43:28 +00:00
tg e88736b5ef decouple conservative file descriptor use from MKSH_SMALL, with the
new MKSH_CONSERVATIVE_FDS præprocessor flag, because Minix 3, for
example, needs it (otherwise “mksh Build.sh” fails)
2009-04-06 08:33:37 +00:00
tg 398be9867a fix jobless mksh so much to make it work on Minix 3 2009-04-05 12:35:32 +00:00
tg 56c6e384e6 (experimental) implement getrusage via times if not found 2009-04-03 09:39:07 +00:00
tg db6ed8be7c ... and it did in fact require DEC ucode cc to spot this!
gcc, SUNWcc, pcc, llvm-gcc, clang, etc. all didn't say a thing!

now compiles warning-free (testsuite pass) on ULTRIX 4.5 (1986),
and OSF/1 X2.0-8 (testsuite norun: perl missing) has only the usual
bitchings about "volatile sig_atomic_t" because the latter part is
already volatile, but otherwise warning-free compile, works fine
2009-03-25 21:45:28 +00:00
tg 99a8c2a814 bump to R37; the ;& and ;;& are postponed indefinitively for now,
as I don't get to it and it's nontrivial
2009-03-22 18:50:43 +00:00
tg 62b28858d4 sync; fold oksh-seterror test into errexit-*; use print not printf 2009-03-22 18:28:35 +00:00
tg 7c77d9369c extend and fix the errexit tests:
* Debian pdksh fails #3 (trap) and #6 (BSD make)
* AT&T ksh93 passes all
* zsh does not pass them literally, but the actual functionality
  checked is right there
* dash fails #3 (trap) and does not pass #6 due to missing [[
* GNU bash 2 (MirPorts) and 3 (Debian) fails #6 (BSD make)
* oksh-current passes all
2009-03-22 15:47:23 +00:00
tg 820df9fcfb on GNU/Cygwin32 at least, “env” does not display its output sorted;
make sort(1) presence a conditional though
2009-03-21 11:09:35 +00:00
tg d8c3d6e9c1 another off-by-one, reported by «macaronyde:#!/bin/mksh» 2009-03-17 13:56:47 +00:00
tg d99541d7c8 revert previous commit for now. testscript which breaks:
H4sIAAAAAAACA31TTUvDQBC951c804DtIQ0iiFhSPHiwiCDqzUpIuhO6JN2ETSS16n93Np+GFiGE
zM6bN2/fTPQOro5xENYuEVLzBz9eaF6RlWupSpyHaXqzVuvyljbbDCRV0UR7WeLiHEtT4D2GCcUy
pdNFh4pkg4wGZCV8Z6opTPOw3GI+swoq4ZIVZxqkSv0JqRAiWkBkmAJNegHIGG9vcAWcSnjM6dTo
uby8vsL7+wLllhQQKKr4SoFv/8nbXE5pQcdpk4nlwH6AE7zer17uVs/BmHVftnUdxYh0yHbV3ghY
9wh2rQlBkdMm8PmIe57Bjfs7dTW9X/OoEG6lwzwnzYKA7+8jHpsJTuFN4+IjKhKZM6dpZ0xuQ2Nz
7bGB1F74zlebmzTm/PS+OB0GZz4HLcPgz+BeDxyS9S7YU6e3qZaQk5gZgRHvQtI59Eet7QwBWFnL
O/F+ej9Fpmg0ug7OHrnqHy2+7y8x6DGEG3E0Az41RuPlYfXEEx0psrl8PAUebzf6ZklabgD8V3SS
Z7Vo6xfOuQS6gQMAAA==

「mksh -o posix z」 failed in that it continues; 「mksh z」 correctly aborts
let’s see what the obsd people have to say herefore
2009-03-16 15:50:13 +00:00
tg e39c1f860d bring back the backed-out Debian patch if FPOSIX; test programmes fixed:
H4sIAAAAAAACAz1PywrDIBA8m68YgoT20EN7TMixX1F6yGNFIWhRSw2h/95VmuDB2XmsY2oDRVyo
Si1N2uHlMzQK0b8JHaImy4RQwxIITYPiUs4xqcyeGgdfrfumtWX5dMbGSHy0WQgP1PJa49lhdpkV
ynncYSxkOjjxd/V83dmcX9sQtFGRi0zORmO5042HbwnMzlIBqa9lAmfLVBIZ7XqpKBPDnDu+WXpi
wMhnOgQXYvUD+oKHAhUBAAA=

XXX OpenBSD has something different which may DTST or even DTRT (not break
XXX our make(1) wrt <bsd.subdir.mk>), check that
2009-03-16 15:14:23 +00:00
tg 7c040d98f9 sprinkle a few static and clean up the internal APIs 2009-03-15 16:13:40 +00:00
tg 32bc1dc40e sprinkle mksh_ari_t to limit arithmetics to 32 bit even
on Debian Lenny/amd64 (XXX need more verification; this
can be used for 64 bit arithmetics later too)

PPID, PGRP, RANDOM, USER_ID are now unsigned by default
2009-03-14 18:12:55 +00:00
tg 1b3e4a3a2e when outputting in a row x column formatted way, but the available space
on the screen is not enough for two columns, just output the text line by
line, instead of trying to format it; gets rid of superfluous empty lines
if we did not even have space for one column on the screen (x_cols)

noticed by Gábor Gergely in irc, thanks!
2009-02-22 18:02:31 +00:00
tg 5e22cb486f <sys/file.h> is only required for, and only contains, flock(2) 2009-02-20 13:25:10 +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 858d8e8b5a implement unsigned arithmetics as an mksh extension 2008-12-17 19:39:23 +00:00
tg 31d1499219 * back out almost all of the memory allocator related changes, as aalloc
was hard to type and hard to fix, galloc is also hard to fix, and some
  things I learned will probably improve things more but make me use the
  original form as base (especially for space savings)
* let sizeofN die though, remove even more casts
* optimise, polish
* regen Makefiles
* sprinkle a few /* CONSTCOND */ while here
2008-12-13 17:02:18 +00:00
tg 732e10c982 comment on slow machines and OEs like GNU/Cygwin32 2008-12-08 13:57:35 +00:00
tg 042086e49e rename utf8-hack to utf8-mode (use set -U or set +U instead, anyway)
and announce less hackish things
2008-12-04 18:11:08 +00:00
tg ef5a465acd fix botched testcase from 10049352E9F5DBF7056 - check.pl offers
a time-limit functionality after all...
2008-12-02 13:19:28 +00:00
tg 330948eafd add a test case for the recursion limit fix 2008-12-02 12:48:16 +00:00
tg 4897682502 Alias expansion has a recursion check which tries to break the cycle if
encountered. However, when reading end of input, the source type is set
to SEOF while popping, whereas the recursion check code only checks for
an SALIAS type.

Fix: add a new SF_HASALIAS flag; change u.tblp from being valid if type
is SALIAS to being valid if SF_HASALIAS is set; set SF_HASALIAS for the
created SALIAS sources; set SF_HASALIAS and u.tblp when creating SALIAS
whose next is SEOF on the SEOF source as well.

Reported by Michael Hlavinka as Redhat Bug #474115
2008-12-02 12:39:38 +00:00
tg 177f707a9f ah, so this is how it fails, in a function! 2008-11-30 16:57:40 +00:00
tg 667c0ba026 add another regression test (XXX why did a similar thing fail?) 2008-11-30 16:53:15 +00:00
tg 65b1e6c09c forgot to bump version here too
savings: 523 .text, 16 .data, 32 .bss (small), ceteris paribus (full)
2008-11-30 10:45:42 +00:00
tg 3c1e46ee4d prepare for aalloc.c, which I have just written myself, as an area-based
allocator using malloc and free, with mmap malloc and omalloc in mind,
not counterfeiting its security measures such as guard pages, and having
some of our own, e.g. XOR random cookies, optional mprotect, etc.

zero cost (for we have arc4random())
2008-11-12 04:55:19 +00:00
tg 2a0e181a70 work around even more format string warning stuff 2008-11-10 19:33:08 +00:00
tg 65b1923b61 build warning-free with LLVM+Clang on MirBSD itself
$ (CCC_LD=mgcc CC=ccc sh Build.sh -r && ./test.sh -v) 2>&1 | tee log
Total failed: 2 (as expected)
Total passed: 278

Just the result is huge, and we could of course build to intermediate
byte code to optimise globally…
2008-11-09 20:32:18 +00:00
tg 446e019c07 the QNX /bin/ed problem is worse than thought; use a new mechanism,
because categories in check.t are OR’d:
• no-stderr-ed disables the newish-ed tests (tried using testcase)
• stdout-ed enables the oldish-ed tests (variable, if the above
  testcase succeeds, it’s added, but QNX overrides the variable)
2008-11-08 17:36:35 +00:00
tg 6e490218ca On QNX, do not run the tests involving /bin/ed at all, because it appears
oldish but is in fact broken. However, if /bin/ed is MirBSD ed(1), these
actually pass.
2008-11-02 23:03:45 +00:00
tg 89e96b6c86 experimental support for <strings.h>
cf. http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html
QNX seems to bury some functions in there
2008-11-02 22:29:36 +00:00
tg 88d7b7d08b • rewrite code to no longer use statements-as-expressions
• optimise a little
• Build.sh: remove HAVE_EXPSTMT test
• Build.sh, */Makefile: sort tests, regenerate
• mksh.hts: sync clog
2008-10-28 14:32:43 +00:00
tg 8230c9d8ae • do not use __typeof__ even if we have statements-as-expressions, to
please pcc, prompted for by Anders “ragge” Magnusson, problem spotted
  originally by Adam “replaced” Hoka
  ⇒ rewrote x_bs2() and utf_backch() into a combined x_bs3() function,
    since these are never used in any other way
• whitespace cleanup, while here
2008-10-26 20:59:40 +00:00
tg bc046dd8f2 this will most certainly be mksh R36 2008-10-24 21:35:43 +00:00
tg 331b45af7d • OSF/1 may not have MAP_FAILED defined either
XXX mmap() works only on devices on some DEC OSes, not on files, so,
  XXX instead, it were best to disable it altogether
• bump date
2008-10-24 19:54:23 +00:00
tg 0c2de1902c • change mksh to only then behave more POSuXish when called as /bin/sh or
“-sh” if -DMKSH_BINSHREDUCED was passed during compilation, for example
  for Debian, but d̲e̲f̲i̲n̲i̲t̲i̲v̲e̲l̲y̲ n̲̲o̲̲t̲̲ for MirBSD™
• split up regression test to force this behaviour
• remove the gunk from our MirBSD™ startup scripts again
• mention arc4random.c changes on website, sync clog, warn packagers
2008-10-20 19:29:25 +00:00
tg 2fc9fb99d7 when doing a history search (^R), restore old input line on
abortion (^G – ^C is SIGINT and doesn’t work like this, but
that’s actually good IMO)

prompted by enquiry about the Emacs editing mode by <smultron:#MidnightBSD>
2008-10-19 20:15:45 +00:00
tg 9be489ea90 use less stack storage, prefer .bss storage (saves us a memset() call)
and .data instead of another initialisation; this was prompted by a bug
in scan-build (the value can never be NULL, but it doesn’t realise it),
although this doesn’t fix it, but less stack usage is always good
2008-10-15 10:25:01 +00:00
tg c11187f993 fix some of the things scan-build[1] found (but not some false positives)
10x

From: Elias Pipping <elias@pipping.org>
[1] http://clang.llvm.org/StaticAnalysis.html
2008-10-13 23:06:04 +00:00
tg 37934a07cf fix prodded by cnuke@ for AIX with IBM xlC 7.0:
fool the compiler into not doing static bounds checking when we do
one-past-the-array-boundary pointer assignments for cases where the
only accesses are like (*--pointer); bump version
2008-10-10 21:30:43 +00:00
tg 5d9e4c9e16 unbreak MKSH_SMALL after x_histp related changes 2008-10-05 16:06:43 +00:00
tg 27ee1866fe implement Message-ID: <20081004171903.GA14184@boetes.org>
in a somewhat hackish way, and it’s still quite different from zsh,
but probably closer to a desired functionality

XXX this makes state by abusing 「modified」 and 「xmp」 (“the mark”).
2008-10-04 23:08:04 +00:00
tg 9cd963ea45 • check.t: change history-e-minus-5 regression test to avoid false failure
caused by ignoredups history control
• histrap.c: enable ignoredups after fc -s editing too
2008-09-30 19:36:16 +00:00
tg b24dc6e725 add regression tests, sync manpage, bump version number 2008-09-30 18:43:07 +00:00
tg b65a7f7f9e bump mksh patchlevel for today’s sorta-tested half-done changes, with more
to follow (see <Pine.BSM.4.64L.0809201417560.22066@herc.mirbsd.org>), as I
probably am not going to hack any more tonight
2008-09-20 19:18:00 +00:00
tg a9342be98a work around GNU getopt(3) violating every single standard in existence 2008-09-19 10:41:55 +00:00
tg 8a853f24be • bring back automatic turn-on of FPOSIX if called as sh/-sh
‣ only if !MKSH_SMALL
  ‣ add appropriate regression test
• if FPOSIX is set, do not close fds > 2 on exec, Debian #499139
• add appropriate regression tests for keeping fds private or not
2008-09-17 19:31:30 +00:00
tg 977237ad14 • merge vi_reset() and edit_reset() into x_vi() to allow for following:
• fix vi mode (which, however, is officially orphaned) multi-line $PS1 by
  using a similar algorithm for prompt skipping as emacs mode (changing
  the meaning of prompt_trunc variable and using prompt_redraw, just even
  more efficiently than vi mode); reported by asarch via IRC
• fix multi-line prompts if last line is “too large” by using emacs mode
  algorithm of just internally appending a newline, while here ☺ this even
  saves us having to re-add the prompt_skip variable…

WARNING: this is only barely tested, as almost nobody ever uses vi mode
⇒ test yourself, there may be bugs (e.g. off-by-ones); already known is
  that the vi input line editing mode is NOT multibyte safe…
2008-09-14 20:24:59 +00:00
tg 9ab67aa02f • merge final version of the stack-free diff as committed by jaredy@openbsd
thanks for helping with the bug
• merge RCS IDs
• bump mksh version
2008-08-02 17:45:12 +00:00
tg 68e028ea4b fixes for constant conditionals, from gcc-4.2 fat binary building 2008-07-18 11:33:13 +00:00
tg eb2db9a35e add comment 2008-07-17 13:00:38 +00:00
tg 828fc5cd8b merge OpenBSD’s non-standard <bsd.regress.mk> tests 2008-07-17 12:57:59 +00:00
tg 5f0269ed9a fix attempt to free pointer to stack (function-local storage)
discovered by Elias Pipping
patch by Jared Yanovich
alloc/afree checker by Todd C. Miller
2008-07-14 12:29:06 +00:00
tg f47d20bc85 bump version 2008-07-12 18:09:37 +00:00
tg 1619fa2538 • Build.sh, check.t: bring back the 'smksh' check category, which was
missing for a while yet its disappearance was unnoticed because…
• distrib/special/mksh/Makefile: sync check categories, this was missed
• mksh.hts: sync clog
2008-07-11 19:51:23 +00:00
tg 81a2b6d878 cygwin has... interesting fs semantics (I got an unaccessible yet
undeletable file on running this manually, which vanished after the
parent(!) process exited), so disable this test for it
2008-07-11 00:23:59 +00:00
tg 99ccfb4024 bump versions (since we lowered the fd limit again) 2008-07-10 21:55:08 +00:00
tg 552d3408e7 oops, only half commit 2008-07-10 21:25:00 +00:00
tg c01bda573f switch back to en_US.UTF-8 for GNU/* too: Mandriva has issues with
en_US.utf8, and Debian (tested on gnubber) can do both
2008-07-10 21:20:22 +00:00
tg 93fcb5a892 on Solaris, this testcase won't produce the issue, but let's pass the test☺ 2008-07-10 20:05:01 +00:00
tg 7c7ecc33be • remove bizarre test constraint
• make a test succeed on Tru64, whose cat likes to output
  │Successful
  │cat: output error
  on this test case
2008-07-10 19:06:15 +00:00
tg ca7cd043db • bump NUFILE and FDBASE, allowing for more than 10 fds used by scripts
• change the code to accept more than a single digit for an fd
2008-07-09 21:32:45 +00:00
tg f4790e8773 add another corner case of here documents, which bash and zsh pass
inspired by:
20:14⎜«twkm:#ksh» $ unset foo ; read -u10 foo 10<<< bar ; echo $foo
which works in ksh93 (whose fd>9-support is still incomplete though)
2008-07-09 20:31:19 +00:00
tg 8f7d2292a8 Debian GNU/kFreeBSD $^O value, 10x tarzeau 2008-07-08 22:29:00 +00:00
tg 064ae65dee reverse the sense of check for en_US.UTF-8 vs en_US.utf8:
the latter is required by HP-sUX, okay, and apparently the
preferred one by glibc (GNU libdrepper?), but breaks on al-
most all other systems I have access to (Slowlaris, Midnight
DragonFly NetBSD, Darwin, at least)
2008-07-08 20:54:33 +00:00
tg 3800eed855 NetBSD® 3.0_STABLE is a tad picky about the UTF-8 locale’s naming… 2008-07-08 20:08:02 +00:00
tg d415592b37 check return value of unlink(2) when trying to remove an existing HISTFILE,
since mksh(1) did go into an infinite loop if that fails first

bug spotted, initial patch and help drafting a test case
From: Decklin Foster <decklin@red-bean.com>

note there are more instances of unlink(2) and others (like chmod(2), as
spotted by flawfinder) which aren’t checked… but at least the other case
of unlink(2) use in histrap.c doesn’t cause any trouble (I think)
2008-07-06 22:41:09 +00:00