[xen-tools] Re: hook scripts issue, and patch

From: Eric Lemoine <eric.lemoine_at_gmail.com>
Date: Thu, 19 Oct 2006 18:21:23 +0200
On 10/19/06, Eric Lemoine <eric.lemoine_at_gmail.com> wrote:
> On 10/19/06, Steve Kemp <steve_at_steve.org.uk> wrote:
> > On Thu, Oct 19, 2006 at 06:06:27PM +0200, Eric Lemoine wrote:
> >
> > > I like the assert() function. I'm currently looking into a solution
> > > that keeps assert() around...
> >
> >   Much appreciated.  I'll not do anything tonight and see if you
> >  find a good solution.  If not I think on reflection I'd be prepared
> >  to lose them.
>
> By the way there's a bug in the assert function. You use the variable
> $line and then $lineno. I'll address that as well if I can come up
> with a good solution.

What do you think about that:

assert ()
{
    lineno="?"

    if [ -n "${LINENO}" ]; then
        # our shell defines variable LINENO, great!
        lineno=$1
        shift
    fi

    if [ ! $* ] ; then
        echo "assert failed: $0:$lineno [$*]"
        exit
    fi
}


Personnally, I like it ;-)

-- 
Eric
Received on Thu Oct 19 2006 - 17:21:32 BST

Mailing list overview.