mksh tag cloud

Sponsored by
HostEurope Logo

mksh tag cloud

All 1 2 3 4 5 6 7 8 9

mksh semantics for evaluating substring expansion ${strvar:pos:len} and string length ${#strvar} expressions has changed today. These operations now work on characters, not on bytes. Characters are octets in non-UTFMODE (which is pretty much the same as bytes, because mksh(1) is a BSD application and, as per style(9), allowed to assume certain things about the environment) and MirOS OPTU-8 multibyte character sequences in utf8-mode.

This means things like typeset -Uui16 -Z7 wc=1#${str::1} now do the right thing (getting you the MirOS OPTU-16 wide character value of the first character in the str).

mksh R38 will thusly be released RSN.

Solución al reto del script

16.05.2009 by tg@
Tags: mksh

asarch ha escrito un artículo acerca de cómo se usa la función isatty(3) de para verificar si un script tiene datos en stdin, quizas en "$@", o para imprimir su uso.

Para el soporte oficial del mksh eres bienvenido en su canal (en inglés, ya que no todos hablan el castellano) en #!/bin/mksh (sí, sí es un nombre válido XD) del Freenode PDPC (

Update: asarch ha corregido mi español... ¡gracias!

mksh $(…) evaluation bug

22.04.2009 by tg@
Tags: bug mksh

RedHat BZ#496791 is another example of a bug I documented better in the commitids 10049EF448F5F89A278 and 10049EF493039137B14 in mksh(1).

The gist is: $(…) are not parsed recursively but by a lexer hack, namely merely looking at matching parenthesēs; this needs to go away. Until then, this bug cannot be fixed.

And while at it, ((foo); bar) subshells need to be fixed so that they are not parsed as ((…)) arithmetic expression with a failure upon encountering a sole closing parenthesis.

The mksh plans list this.

Not an mksh bug

08.04.2009 by tg@
Tags: bug debian mksh

When R37c was brought out, I fixed a bug on (among others) IA64. The simple memory allocator added a pointer (or two, in Espie's) to the storage, placed before what the user got. Of course, gcc wanted to align the struct not taking this into account, failing evilly. Luckily, another FTBFS was not my fault, but sigsetjmp(3) was merely broken on S/390 with dietlibc; waldi fixed it in the meanwhile, but I uploaded another version of mksh to Debian for now whose mksh-static binary links against glibc instead and added me a TODO bug.

All the testsuite failures are certainly interesting though; the hppa one looks like a bug in ed(1) there; as to the others, either Perl, or binfmt_misc was configured to accept or drop (but not reject) shebangs præfixed with a BOM. Whatever.

Maybe I can now finally go back to working on MirBSD instead? :D
After all, we want a new snapshot (for NetInstall, at least).

The MirBSD Korn Shell R37c has been released. You do not need to update if you are already running R37b, unless one of the following items affects you:

  • Fix a file descriptor bug on Minix 3 (all users are affected, unless their Minix 3 version supports >64 fds already)
  • Support ACK on Minix 3 by means of a workaround
  • Change structure alignment and padding (affects people getting a SIGBUS or sometimes SIGSEGV on strict-alignment arches, e.g. IA64)

Since bsiegert@ has not indicated willingness to take over Freshmeat announcements of mksh releases, and I am almost unable and certainly unwilling to, this ceases our use of said site's services. Please use to keep informed about things related to the MirBSD Korn Shell.

The MirBSD Korn Shell R37b has been released, incorporating a plethora of changes from R37, which was only available from CVS, and a few news by itself.

The new ‘-combine’ option (gcc4 only) is about as noteworthy as the Minix 3 support. Users of Emdebian, FreeWRT and Beastiebox however will find that the new memory allocator has less overhead, i.e. the shell shrank in size. On the other hand, it is now much more standards compliant, especially wrt. “set -e”.

As such, mksh R37b is a strongly suggested upgrade.

Note: Freshmeat has a new website. I am utterly confused from it, both in Lynx and Opera, so I don’t know if this announcement has made it to there. I probably will cease to use Freshmeat, similarily as Slashdot, when it became unusable in Lynx. Damn “Web 2.0”!

mksh at Apple again

05.04.2009 by tg@
Tags: mksh

laffer1 remembered me of Benny’s Apple bug report about mksh inclusion into their base system. He also did it back then, as requested, and the bug #6735470 would be the result. Unfortunately, one still cannot get a publicly accessible version of them.

By the way, the R37b version is out.

[rant] FreeBSD® sucks!

29.03.2009 by tg@
Tags: bug mksh snippet

How about this:

	tg@herc:~ $ /bin/sh -c 'echo "0=($0) 1=($1) 2=($2) 3=($3)"' -- a "b c"
	0=(--) 1=(a) 2=(b c) 3=()
	tg@herc:~ $ nbsh -c 'echo "0=($0) 1=($1) 2=($2) 3=($3)"' -- a "b c"
	0=(--) 1=(a) 2=(b c) 3=()

Heck, not just NetBSD® ash, and almost any shell Debian can dig out (bash pdksh ksh93 zsh dash posh) behaves the same as mksh.

MidnightBSD (DragonFly and FreeBSD too):

	tg@mnbsd:~ $ /bin/sh -c 'echo "0=($0) 1=($1) 2=($2) 3=($3)"' -- a "b c"
	0=(a) 1=(b c) 2=() 3=()

And the best thing of all: I am to "fix" this in mksh, as the old FreeBSD® ash is documented to have that weird behaviour. (Well, there's always -DMKSH_BINSHREDUCED...)

This is not a fault of MidnightBSD (except they could fix mports to behave more POSIXish; after all, I had to do that to MirBSD and MirPorts often enough), don't get me wrong. It just surprised me, and since I'm glad they switched to mksh as /bin/sh I basically had to debug it.

I don't remember any more what NetBSD® 1.5 did that its /bin/sh could not be replaced by mksh, but they fixed it in 1.6 – K?buntu (the LTS version) fscks up similarily...

mksh, the MirBSD™ Korn Shell, is not only the MidnightBSD /bin/ksh, it is now their default /bin/sh as well! See the commit message for details.

laffer1@mnbsd and tg@mbsd worked together to create compatibility code for the FreeBSD® ash extensions; the version R37 of mksh(1) used already has been proven as /bin/sh in MirBSD and FreeWRT for some time, and Debian as well, which provided valuable corner case tests leading to eventual bugfixes.

We can only suggest others follow ☺ Apple, pkgsrc®, where are you?

mksh improvements

22.03.2009 by tg@
Tags: mksh

Today's commits should fix Debian #518359 (not tried yet, as looking at a 14" Belinea 10 40 40 CRT makes my eyes and head hurt), as well as improve a lot of more things.

The mksh(1) echo builtin now behaves more POSIXly in "set -o posix" mode (or when called as "sh", if that feature was set at compile time). The exact feature set is negotiable, if certain parties, say pkgsrc®, are interested.

Thanks to the OpenBSD developers for improving their ksh as well.

The ;& and ;;& features are delayed for now though, sorry.

We're in a feature freeze; people please test mksh-current on your system to make R37 rock!

The MirOS Project News in the upcoming February issue of the BSD magazine contains a mention of mksh R37 with a new memory allocator. This will, however, be postponed, because I could not get it right in time (even though I learned from the first tries – and wish I could write it in i386 assembly) and lost interest for now, as the current one still does work. I may revisit that at a later date.

Fixing the PS1 bug, maybe changing the echo builtin to SUSv3 (and nothing more), maybe porting, are on the list, besides continuing the Coverity Scan fixes.

more bugs – bootloader and mksh

01.02.2009 by tg@
Tags: bug event grml mksh snapshot

Again. I almost have a MirGRML+bsd4grml ISO ready (exactly 72 MiB), just for the fun of it, and so that people can toy with it – and test the integration. But nooo, I even hacked a disklabel, yet it wouldn’t access the filesystem. The “machine label” command shows what’s wrong (and hints how to fix it), and I missed a corner case in disc I/O due to adding two not-so-independent-from-each-other scenarios during the El Torito merge.

mksh has funny behaviour with ${foo/@(%)/x} failing – only in Unicode mode though.

All 1 2 3 4 5 6 7 8 9

MirOS Logo