For some time I have been meaning to check out mksh, and your email 
prompted me to install it. The first thing I noticed was how good the 
documentation is (the bash man page is missing a lot of stuff).

I played around with mksh for a while and noticed some other differences 
with bash. Parameter assignment using here-docs is a nice feature. Another 
difference is double logical complement. The mksh result was the one I was 
expecting --

mksh:

$ ! ! perl -e 'exit 2' ; echo $?
1
$ ! ( ! perl -e 'exit 2' ) ; echo $?
1
$ ! { ! perl -e 'exit 2' ; } ; echo $?
1

bash:

$ ! ! perl -e 'exit 2' ; echo $?
2
$ ! ( ! perl -e 'exit 2' ) ; echo $?
1
$ ! { ! perl -e 'exit 2' ; } ; echo $?
1


Another difference is parameter assignment --

mksh:

$ a=x
$ a=blah :
$ echo $a
blah
$ a=foo exec </dev/stdin
$ echo $a
foo

bash:

$ a=x
$ a=blah :
$ echo $a
x
$ a=foo exec </dev/stdin
$ echo $a
x

The mksh man page says, "the assignments are in effect only for the 
duration of the command". In bash you might do,

$ a=blah $cmd

and get different results; given cmd="" the assignment sticks, but given 
cmd=":" the assignment is a NOP. Could be useful perhaps.

On the other hand...

mksh:

$ cmd=
$ exec $cmd
$ cmd=:
$ exec $cmd
[terminates]

bash:
$ cmd=
$ exec $cmd
$ cmd=:
$ exec $cmd
-bash: exec: :: not found
$ 

So is ":" a NOP, or is it a builtin command? Beats me!


Anyway, I'm picking nits. Here's where the rubber hits the road:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM     TIME+ COMMAND            
12457 fthain    20   0  3524 1872 1572 S  0.0  0.1   0:00.01 bash               
12734 fthain    20   0  2228  712  608 S  0.0  0.0   0:00.00 mksh               

$ ls -l /bin/mksh /bin/bash
-rwxr-xr-x 1 root root 263860 Mar 29 12:51 /bin/mksh
-rwxr-xr-x 1 root root 720796 Sep  3  2012 /bin/bash


So thanks for the excellent work!

Finn


P.S. For the sake of completeness:

$ /bin/mksh -c echo\ \$KSH_VERSION
@(#)MIRBSD KSH R44 2013/02/24

$ /bin/bash -c echo\ \$BASH_VERSION
4.2.37(1)-release


P.P.S. I'm not subscribed so please Cc replies.

Reply via email to