Re: [ILUG] shell script Q

From: Kenn Humborg (kenn at domain avalon.wombat.ie)
Date: Sat 18 Sep 1999 - 14:00:31 IST


On Fri, Sep 17, 1999 at 11:37:08AM +0100, John P . Looney wrote:
> I'm trying to implement the equivelant of assert(3) in a shell script.
> Simple enough;
>
> if ! [ "$DEBUG" != "" ] ; then
> assert ()
> {
> if ! [ $* ] ; then
> echo "assert failed: [$*]"
> fi
> }
> else
> asser () {}
> fi
>
> And, later, call it with:
>
> assert "$#" == "5"
>
> Is there any way I can print out the name of the shell function that
> assert() was called from ?

I bought the O'Reilly bash book a few days ago, and it mentioned something
about being able to write your own builtin functions as shared libs.

So, if is only for development purposes, you could do it that way and
presumably have full access to bash's internal data structures.

I can't give any more details because the book is in the office and I'm
not.

Later,
Kenn



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:34 GMT