Re: a 'type' script for mu (Repost...)

From: Alfie Costa (agcosta@gis.net)
Date: Fri Mar 10 2000 - 19:15:12 CET


On 3 Mar 00, at 21:47, Michele Andreoli <mulinux@sunsite.auc.dk> wrote:

> Added "type" as script in /bin. Are you dealing with ash bugs,
> isn't true?

Hello, sorry for the late reply, I started out trying to do one thing, then
wound up doing another, which took longer than it was supposed to; however, the
goal is still to speed up that 'type' script some, and that's what led to
several detours...

Maybe some trouble is being caused by ash bugs; perhaps ash doesn't do as one
might expect because of bugs, or because it was intentionally designed that
way. Lately I've been trying to find the source code of the most upstream,
Mother-Of-All-ash-Variants, to see if offers any clues. It's hard to find, but
is believed to reside somewhere in the NetBSD CVS tree. Perhaps somebody on
this list knows where to find this elusive official NetBSD ash code. (?)

The ash trick I'm interested in has to do with case...esac's pattern matching.
For example here is a routine to count characters...

case Z$1 in Z) echo no characters ;; Z?) echo 1 char ;; Z??) echo 2 char
;; Z???) echo 3 char ;; Z*) echo 4 or more chars ;; esac

Depending on what's in the string, it will return surprising numbers.
Even for a single character sometimes.

I tested all 255 possible bytes, and compared these to the output of 'wc'. The
current rustic mu-awk 'wc' doesn't like binary data though, so this led me to
hack out a fancier 'wc'...

But a digression about this 'wc' should be on another thread, and maybe
"case..esac's" peculiarities ought to as well. Off to start more threads
then...

---------------------------------------------------------------------
To unsubscribe, e-mail: mulinux-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: mulinux-help@sunsite.auc.dk



This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:13 CET