bug-bash
[Top][All Lists]
Advanced

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

Re: Odd LINENO behaviour in 'eval'


From: Chet Ramey
Subject: Re: Odd LINENO behaviour in 'eval'
Date: Mon, 20 Mar 2017 10:00:21 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 3/19/17 10:58 PM, Martijn Dekker wrote:
> Test script:
> printf "$LINENO "
> printf "$LINENO "
> eval '        printf "$LINENO "
>       printf "$LINENO "
>       printf "$LINENO " '
> printf "$LINENO\n"
> 
> Output on various shells:
>             bash: 1 2 5 6 7 6  (?!)
>      {m,l,pd}ksh: 1 2 0 0 0 6  (?)
>       AT&T ksh88: 1 2 3 3 3 6
>       AT&T ksh93: 1 2 1 2 3 6
>       FreeBSD sh: 1 2 1 2 3 6
>             dash: 1 2 1 2 3 6
>             yash: 1 2 1 2 3 6
>     zsh (native): 1 2 1 2 3 6
>         zsh (sh): 1 2 3 3 3 6  (like ksh88)
> 
> It is unclear to me why bash starts counting the 'eval' lines at 5. Is
> this a bug?

Line 5 is the line that gets assigned to the `eval' command because that
is the current line when the complete command is parsed.  You don't
really know the current line when a simple command starts to get parsed
(well, you do, but you don't really know when the simple command gets
started when you're dealing with bison).

Bash used to reset the line number to 1 when executing an `eval', but I
changed that back before bash-3.0 due to user requests.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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