bug-bash
[Top][All Lists]
Advanced

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

Re: trap 'echo "trap exit on ${LINENO}"' EXIT -> wrong linenumber


From: Jochen
Subject: Re: trap 'echo "trap exit on ${LINENO}"' EXIT -> wrong linenumber
Date: Wed, 08 Dec 2010 15:51:38 -0000
User-agent: G2/1.0

On 18 sep, 22:22, Eric Blake <address@hidden> wrote:
> On 09/18/2010 12:18 PM, Chet Ramey wrote:
>
> > On 9/18/10 12:57 PM, Eric Blake (cygwin) wrote:
> >> On 09/17/2010 06:37 PM, Chet Ramey wrote:
> >>> I guess you could make a case to not reset $LINENO for the exit trap
> >>> due to this sentence in Posix (though $LINENO is not Posix):
>
> >> LINENO may be optional in the bare minimum POSIX compliance, but it is
> >> certainly specified
>
> > You're right.  I guess the real question is what happens to LINENO
> > when `eval' is executed.  bash, ksh93, and zsh do different things,
> > and dash doesn't support LINENO at all.  Posix says that trap actions
> > are processed as if executed by eval.
>
> Actually, dash 0.5.6 added rudimentary LINENO support (more precisely,
> dash.git commit 0df9679 in Aug 2009), all because POSIX requires it.
> But you are certainly correct about LINENO support differing wildly by
> shell, even without throwing functions, traps, and eval in the mix:
>
> $ str='echo $LINENO\
> \
> \
>   && echo $LINENO
> echo $LINENO'
> $ dash -c "$str"
> 1
> 1
> 1
> $ bash -c "$str"
> 3
> 3
> 4
> $ echo "$str" | dash
> 1
> 1
> 2
> $ echo "$str" | bash
> 4
> 4
> 5
>
> --
> Eric Blake   address@hidden    +1-801-349-2682
> Libvirt virtualization libraryhttp://libvirt.org

Thanks for the replies!

Is there some other way to find out on which line a script exits?

Jochen


reply via email to

[Prev in Thread] Current Thread [Next in Thread]