[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Possible bash2 bug

There's a possible bug in bash 2.04.0 (i.e. our shells/bash2 port).

A friend of mine came up with this towers of hanoi script that he
keeps in his signature:

m(){ if [ $1 -eq 1 ];then echo $2 $3;else m $(($1-1)) $2 $4 $3;m 1 $2 \
$3 $4;m $(($1-1)) $4 $3 $2;fi;};if [ $# -eq 3 ]&&[ $3 -ge 1 -a $1 -le \
3 -a $1 -ge 1 -a $2 -le 3 -a $2 -ge 1 -a $1 -ne $2 ];then m $3 $1 $2 $\
((6-$1-$2)); else echo Usage: /bin/sh hanoi.sh from to num; fi #by rhb

On FreeBSD/alpha, "bash hanoi.sh 1 2 3" will cause bash to dump
core.  Mandrake Linux has a patch that fixes this.  I'm considering
eventually including this patch in our port.

(Un)fortunately, bash2 built on OpenBSD/i386 doesn't have this
problem for me.  So, before I worry about patching away a nonexistent
bug, does bash dump core for somebody else with this script?  In
particular on non-i386 platforms?

PS: pdksh, i.e. our (k)sh, is about 2.5 times faster than bash for this
    script.  An old ksh93 binary I have lying around is again twice as
    fast as pdksh.
Christian "naddy" Weisgerber                          naddy_(_at_)_mips_(_dot_)_inka_(_dot_)_de

Visit your host, monkey.org