[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wrong lineno inside trap?
From: |
Chet Ramey |
Subject: |
Re: wrong lineno inside trap? |
Date: |
Mon, 12 Jan 2009 10:22:52 -0500 |
User-agent: |
Thunderbird 2.0.0.19 (Macintosh/20081209) |
peter360 wrote:
> I wrote a test program test.sh:
> ----------------------------------------------------
> trap '
>
> echo this is line 3, but LINENO=$LINENO
>
> ' 0
>
> echo this is line 7, and LINENO=$LINENO
> ---------------------------
> when I ran it I got
> $ sh /tmp/test.sh
> this is line 7, and LINENO=7
> this is line 3, but LINENO=11
>
> My bash version is
> $ sh --version
> GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
> Copyright (C) 2005 Free Software Foundation, Inc.
>
> Is this a known problem? Thanks.
Bash-4.0 should behave better in this area, but quoted strings will
always cause unpredictable values for $LINENO.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/