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   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to