Commit Graph

238 Commits

Author SHA1 Message Date
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 c8eb13a13f align with C standard (optional C style); document differences to C style
for print builtin (align with ksh93 ipv GNU bash)
2009-09-19 19:08:48 +00:00
tg 7806fe510a allow “function stop () {” (bashism, an evil one) 2009-09-19 18:36:59 +00:00
tg e0f000fb83 new function unbksl doing "backslash expansion" independent of c_print();
also make a separate subsection about it in the manpage
2009-09-19 15:16:05 +00:00
tg 3639137e48 another ksh93 feature: test -o ?foo (almost zero cost) 2009-09-07 17:24:49 +00:00
tg ce24c5da13 • more on pipelines vs subshells
• remove some superfluous spaces
2009-09-06 18:17:51 +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 574d6725aa document more differences to ksh93; here: static vs dynamic scoping 2009-09-05 17:12:49 +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 75a7eb63e1 document the _possible_ printf(1) builtin and mark that it’s not supported 2009-08-30 11:38:44 +00:00
tg 09abc55150 documentation and test suite for tonight’s new features, ☾ gn8 2009-08-28 22:46:21 +00:00
tg d5d6e97683 implement "typeset ±a" as no-op 2009-08-28 21:51:52 +00:00
tg a95b90b79f add the keyword “colour” to the PS1 example, since it wasn’t found in
here in either spelling and smultron@ wanted to see how it’s done
2009-08-14 09:00:30 +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 e42e775d9b sync special commands list (XXX why is alias there twice? pdksh.deb too…) 2009-07-08 10:37:24 +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 0b4b689c92 note that ${foo//bar/baz} may need the pattern escaped; discovered by me
for # and %, and by Matt Lewandowsky («lewellyn:#ksh») for & as pattern.
2009-07-06 09:37:03 +00:00
tg 25ea755f54 wbx@ requested that his feature is not called his feature 2009-06-21 15:43:17 +00:00
tg 63c56000f7 sync with oksh:
Revision 1.129: [7]download - view: [8]text, [9]markup, [10]annotated - [11]select for diffs
   Thu May 28 06:09:06 2009 UTC (3 days, 11 hours ago) by jmc
   Branches: [12]MAIN
   CVS tags: [13]HEAD
   Diff to: previous 1.128: [14]preferred, [15]coloured
   Changes since revision 1.128: +6 -6 lines
fix missing bracket by slightly rewriting; from Alan R. S. Bueno
2009-05-31 17:41:09 +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 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 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 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 36f737f5cb bind new search-history-{up,down} to ANSI PgUp and PgDn keys
“because we can”
2009-05-16 14:45:40 +00:00
tg e7c565b2aa document currently bound ANSI cursor keys (↑↓←→ Home End Del) 2009-05-16 14:44:37 +00:00
tg 1535151525 fix typo 2009-05-16 14:34:58 +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 eb3f3d584f move pdksh and contributor dedication into TFM, preparation for things
to come
2009-05-16 14:17:39 +00:00
tg 3765851432 address RedHat BZ#496791: fix currently not possible, because the code
which escapes $(…) content does not know if an imbedded ‘#’ is a comment
leader or something else like “16#foo”, “${#bla[*]}”, “${foo#bar}”, &c.
and the comment skip code does not know about nesting beforehand
⇒ document this problem in the place where it already documents that
  the current code does not properly handle nested $($(…)) expressions

patches welcome
2009-04-22 16:25:12 +00:00
tg 7463e5daa7 fix an oversight 2009-04-07 21:23:28 +00:00
tg ecef21a50a switch mail address to .org domain 2009-04-07 19:46:55 +00:00
tg 3dc6b813fd • document new (clarified) macro behaviour – bugfix
• make bind ^X vs ^[[ section more clear
2009-04-05 12:45:25 +00:00
tg 44202462f5 even more clear; ok «gps23» 2009-03-23 12:21:02 +00:00
tg a6d9fe51dc give example 2009-03-23 12:16:58 +00:00
tg c37c7aea61 document somewhat surprising behaviour
12:58⎜<gps23:#ksh> someone please tell me why:   code=1; if [ "code" -eq 1 ] returns true
13:10⎜<mira|AO:#ksh> hm but I see the problem
13:10⎜<mira|AO:#ksh> code=1; x=code; [ "$x" -eq 1 ]
13:10⎜<mira|AO:#ksh> this is indeed unexpected
13:10⎜«pgas:#ksh» gps23: code=1+1;[ "code" -eq 2 ] && echo true #also works
as of now, we consider
13:13⎜«pgas:#ksh» gps23: when you use -eq there is something like an implicit $(( )) around the
     ⎜    arguments
13:14⎜«pgas:#ksh» [ code -eq 1 ] is the same as [ $((code)) -eq 1 ]
to be documented.
2009-03-23 12:15:33 +00:00
tg bf7c84eef6 merge manpage and sync RCS IDs
not merged: POSuX character class nonsense
2009-03-22 18:09:17 +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 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 ee0f60411c 64 bit mksh do not limit to 32 bit integer variables in *all* places ☹
XXX this has to be sorted out; we want to bump the internal integer
XXX types to 64 bits some day anyway
2008-12-17 19:32:47 +00:00
tg 4d56eb849c if we set the S̲pacing m̲ode to off, we must set it back to on too 2008-12-17 19:25:54 +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 5ac371071d replaced (TNF: ahoka) insists on me mentioning that we specify integer
silent wrapping (gcc -fwrapv) as expected behaviour
2008-10-24 21:27:20 +00:00
tg e755d6d2a9 some more manual page improvements 2008-10-20 19:52:07 +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 52339e8a77 fix botched up manpage diff 2008-10-04 23:22:13 +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 d44827dc5b fixes 2008-09-30 18:48:01 +00:00
tg b24dc6e725 add regression tests, sync manpage, bump version number 2008-09-30 18:43:07 +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 a04ad530a2 sync with reality 2008-09-17 19:27:16 +00:00
tg 97aaad43b2 mention that the vi editing mode is orphaned (almost no users, really no
developers, I understand about 1% of the source code only) yet still
functional (just not en par with the emacs editing mode, but no known
regressions over oksh (in -current) and better functionality than most
other korn shells, according to Yofuh)
2008-09-14 20:56:06 +00:00
tg f341615e2c be more efficient 2008-08-14 17:39:30 +00:00
tg 027e9efa85 mention MirOS OPTU-8 (and OPTU-16) encoding some more 2008-08-02 00:57:28 +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 c77d67ef4d • add code to support GNU bash’s “&> file” I/O redirection extension,
and make it fit into mksh’s model (also gives us a couple of things
  GNU bash doesn’t have
• add regression tests for all of these

Lukas “smultron” Upton from MidnightBSD spotted a script with /bin/sh
shebang invalidly using “&>” in some Apple backup toolkit, 10x

XXX why fds are limited to one digit?
2008-06-28 22:51:56 +00:00
tg e91eab65a8 sort argument list, inspired by commit from Igor Sobrado 2008-06-08 16:57:52 +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 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 4e53710a01 NUL bytes don’t work 2008-05-10 18:10:02 +00:00
tg c5db7903dd if we don't have setlocale(), just look at the env vars ourselves 2008-05-04 01:58:15 +00:00
tg 604ec0ff6c remove dead code and ifdefs, speed up configuring 2008-05-04 01:51:31 +00:00
tg 7dd741a401 • revert the oksh code to be able to set multiple ulimits in one
invocation, until it works with a common idiom: “ulimit -dS 262144”
  (but keep some goodies)
• add a regression test for that
2008-04-20 21:30:29 +00:00
tg c21dd61fd3 make it clearer (and most people don’t know what CESU-8 is, anyway) 2008-04-20 01:47:59 +00:00
tg c312619cc9 ok, so instead of removing the “-o utf8-hack” behaviour of the 1#* operator
we just tell the user to only throw valid CESU-8 or single octets on it
2008-04-20 01:12:52 +00:00
tg 309c674ed7 mostly revert 100480A853206FB56FA and parse utf-8 lead bytes ourselves 2008-04-20 00:24:26 +00:00
tg f1ab7789e3 solve the issue (although not quite how I’d like it) 2008-04-19 23:49:59 +00:00
tg 9b62cf15bf • more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
  at non-interactive startup, enabled at interactive startup, if the
  current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
  change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
  sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
  ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
  or do the same as print \x## or \u#### (depending on the utf8-hack flag),
  plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
  (print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
  base-0 numbers which I had planned to use for raw octets first, as they are
  used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
tg 4d978af3da mention -Z padding behaviour change (= fix)
pdksh and oksh are wrong here
2008-04-19 21:18:52 +00:00
tg 6c6be2a87e _careful_ (feature) sync with oksh:
(3 weeks, 5 days ago) by millert
Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do.  Requested by espie@, OK deraadt@
2008-04-16 21:56:03 +00:00
tg 828fbed741 • adjust the regression test so that the behaviour of export and readonly
matches mksh pre-R29 (the one introducing the bug), and typeset matches
  the behaviour intended with the R29 changes (better AT&T ksh93 compati-
  bility) but never reached
• adjust the man page description of “typeset -p”, as it’s different from
  the “typeset” and “typeset -” actions
2008-04-01 21:07:20 +00:00
tg 83b8798da3 support dæmonisation in mksh, for example
|	csh -cf '/command/svscanboot &'
and
|	/usr/mpkg/bin/pgrphack /usr/mpkg/bin/svscanboot &
can now be replaced with
|	/bin/mksh -T- /usr/mpkg/bin/svscanboot
2008-03-23 22:09:59 +00:00
tg 231b682cdf according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 00:09:34 +00:00
tg 8a3169a0dd Patrick “aptituz” Schoenfeld mentioned “lintian -viI mksh*.changes” to
me, which points out that “gnroff -Tutf8” mangles the ‘-’ characters
(hyphen/minus) from the input into ‘‐’ characters (hyphen), which does
not make sense in many cases and prevent copy’n’paste → fix

no change in nrcon output
2008-03-03 22:38:41 +00:00
tg 36c4552e1f we don't need to be special if called as -sh any longer now 2008-03-01 02:21:38 +00:00
tg f87b33997a two small fixes: ① cvs doesn’t like me; ② .Nm only takes one word argument 2008-02-29 18:20:16 +00:00
tg 252a4b13cc use $Mdocdate here, too (extend .Dd of GNU groff first) 2008-02-29 11:03:55 +00:00
tg 85b0cb20eb almost hack ${foo//bar/baz} support for real, now
still one corner case left ☹
→ 11:09⎜«Han:#UnixNL» Ik _haat_ bash
⇒ kann ich mich nur anschließen…
2008-02-27 11:24:12 +00:00
tg 5ea53a15c7 implement “here strings” 2008-02-26 20:43:11 +00:00
tg 5468e6ee12 now we don’t need more special FPOSIX behaviour any more 2008-02-25 00:58:26 +00:00
tg d16fc19335 live code from FOSDEM: add print \xDB and \u20AC, including regression test
agreed bsiegert@
good idea and manpage diff ok'd by some netbsd person sitting next to me
2008-02-24 15:48:43 +00:00
tg 2ca968e25f • fix for the pipeline-as-coprocess problem
• bump to mksh R32
2007-10-25 13:51:19 +00:00
tg 97ba2fabc7 first step towards mksh R32 ☺
allow array indices in the uint32_t range (0‥4294967295) and map negatives
into that range; adjust manual page and regression tests; to be used RSN ☻
2007-10-18 20:32:33 +00:00
tg 80e0de3f98 mention interactive shells processing ~/.mkshrc 2007-10-14 13:43:17 +00:00
tg 307330bee2 be more accurate but terse regarding pipe sequences
somehow, variables don’t propagate up much more often
2007-09-26 19:26:58 +00:00
tg 957291d4b8 sync: “unset” always returns zero as per SUSv3 2007-09-09 19:18:59 +00:00
tg ca46f3dc98 new builtin “rename” (this name sounds better than “mksh_mv_rescue” ☻)
to just call rename(2) directly, e.g. if /bin/mv needs /lib/ld-uClibc.so.0

some assorted code cleanup
2007-08-19 22:06:27 +00:00
tg 49c95a8938 put clear-screen on ESC ^L as suggested by the AT&T ksh people in
http://www.opensolaris.org/os/community/on/flag-days/pages/2007081701/
2007-08-18 01:20:28 +00:00
tg e99f988aae feature freeze for mksh R31, to be released as part of MirOS #10 2007-08-18 00:22:09 +00:00
tg f684b0ceb1 Implement the “source” command, as requested by some and agreed bsiegert@
In contrast to AT&T ksh93, its semantics are like GNU bash in that it ap-
pends the current working directory to the search path; it is implemented
as a shell alias instead of enhancing funcs.c:shbuiltins[] like in ksh93.
2007-08-13 19:39:21 +00:00
tg 7381c6c274 mention that $RANDOM is _always_ 15-bit unsigned integer, even arc4random’s 2007-08-12 14:01:38 +00:00
tg 499327f7b8 add “set -o arc4random”, RTFM for details 2007-08-12 13:42:23 +00:00
tg 47836e45e7 add a new bindable command “clear-screen”, which can be bound to the ^L key
so that archite@midnightbsd won’t have to add evil kludges to oksh again if
they switch their ksh to mksh ☺

both “clear-screen” and “error” aren’t bound; default binding for ^L stays,
as usual, “redraw” (principle of least surprise); however GNU bash converts
also might want to put “bind ^L=clear-screen” into their ~/.mkshrc.
2007-07-31 15:29:40 +00:00
tg b8a693ed68 mention ${foo:2:3} limitations 2007-07-26 13:32:16 +00:00
tg 78d58de7a0 fix the rest of it 2007-07-06 02:22:57 +00:00
tg ca17798533 this is bash compatibility week, and by suggestion of actual users,
namely Dr. Robert “Pfeffer” Arnold (in this case, in FreeWRT), make
a half-completed attempt at implementing ${foo:2:3} substring evals
(of course, negatives can't work right now and that the numbers are
in face expressions is something I only read later too – this is to
be revisited later, but it's already late)

don't depend on this behaviour yet though

if someone wants to add more regression tests, feel free to…
2007-06-27 23:12:59 +00:00
tg 7796820c82 now that we're definitively at 40 pages for the PDF manual, revert some of
the changes in r1.81, and improve wording further
2007-06-23 19:07:14 +00:00