tech-userlevel archive

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

Re: mksh import



,--- You/Christopher (Wed, 5 Jan 2011 20:53:41 -0500) ----*
| I noticed that several of the shells croaked while trying to execute
| the script. I know that I had some troubles with the 'let' and
| '{-20..20}' features (among a couple others). I've slightly
| rewritten that script to make it run on NetBSD's /bin/sh -- so it
| should be highly portable (I think).

| Here is the results from running on NetBSD 5.1 with /bin/sh:
| 
| ==================================
| NetBSD: /bin/sh
| 
| real         0.87
| user         0.40
| sys          0.46
|
`---------------------------------------------------------*

Here are my results with your slightly modified (see at the bottom) script:

========================================
FreeBSD 8.2-PRERELEASE
====================

--- /bin/sh -->
real    0m0.873s
user    0m0.232s
sys     0m0.663s
<-- /bin/sh ---

--- /usr/local/bin/bash -->
real    0m1.863s
user    0m0.761s
sys     0m1.102s
<-- /usr/local/bin/bash ---

--- /usr/local/bin/ksh -->
real    0m0.722s
user    0m0.229s
sys     0m0.503s
<-- /usr/local/bin/ksh ---

--- /usr/local/bin/ksh93 -->
real    0m0.244s
user    0m0.220s
sys     0m0.009s
<-- /usr/local/bin/ksh93 ---

========================================
AIX 3
====================

--- /bin/bsh -->
./mandelbrot2.sh: syntax error at line 22: `(' unexpected
<-- /bin/bsh ---

--- /bin/bash -->
real    0m2.035s
user    0m1.177s
sys     0m0.340s
<-- /bin/bash ---

--- /bin/ksh -->
real    0m1.306s
user    0m0.681s
sys     0m0.410s
<-- /bin/ksh ---

--- /bin/ksh93 -->
real    0m0.154s
user    0m0.094s
sys     0m0.015s
<-- /bin/ksh93 ---

========================================
Linux 2.6.18-92.el5PAE
====================

--- /bin/sh -->
real    0m2.339s
user    0m1.297s
sys     0m0.963s
<-- /bin/sh ---

--- /bin/bash -->
real    0m2.278s
user    0m1.313s
sys     0m0.924s
<-- /bin/bash ---

--- /bin/ksh -->
real    0m0.307s
user    0m0.260s
sys     0m0.004s
<-- /bin/ksh ---

--- /bin/ksh93 -->
Not found
<-- /bin/ksh93 ---

========================================
SunOS 5.10
====================

--- /bin/sh -->
./mandelbrot2.sh: syntax error at line 22: `(' unexpected
<-- /bin/sh ---

--- /bin/bash -->
... interrupted ...
<-- /bin/bash ---

--- /bin/ksh -->
... interrupted ...
<-- /bin/ksh ---

--- /bin/ksh93 -->
Not found
<-- /bin/ksh93 ---

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
case $(uname -s) in
  FreeBSD) seq=/usr/local/bin/gseq;;
  Linux) seq=/usr/bin/seq;;
  AIX) seq=/opt/freeware/bin/seq;;
  SunOS) seq=/opt/sfw/bin/seq;;
esac

range=`$seq -20 20`
# echo 'range=[' $range ']' >&2

inmandelbrot() {
    mag=$(($1 * $1 + $2 * $2))
    if [ $mag -gt "40000" ] || [ $5 -ge $6 ]; then
        echo $5
    else
        r=$((($1 * $1)/100 - ($2 * $2)/100 + $3))
        i=$((($1 * $2)/100 * 2 + $4))
        cnt=$(($5 + 1))
        inmandelbrot r i $3 $4 $cnt $6
    fi
}

for y in $range; do
    for x in $range; do
        rval=$((x * 10))
        ival=$((y * 10))
        val=$(inmandelbrot rval ival rval ival 1 10)
        if [ $val -eq 10 ]; then
            echo -n ".";
        else
            echo -n $val;
        fi
    done
    echo
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- Alex -- alex-goncharov%comcast.net@localhost --



Home | Main Index | Thread Index | Old Index