bug-bash
[Top][All Lists]
Advanced

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

Re: unreliable value of LINENO variable


From: Chet Ramey
Subject: Re: unreliable value of LINENO variable
Date: Mon, 4 Dec 2023 12:21:11 -0500
User-agent: Mozilla Thunderbird

On 12/4/23 8:46 AM, Giacomo Comes wrote:
I use often the value of LINEO in order
to know where to look for issues in a script.
Recently I discovered a bug.

Please consider the following 6 line script:
------------------------------------------------
#!/bin/bash

if ((1)); then
        ( : ) ; echo 1 $LINENO
fi
echo 2 $LINENO
------------------------------------------------
if executed it should print:
1 4
2 6
And indeed that's the output if I run it on openSUSE Leap 15.5
(bash 4.4). However if I execute it on openSUSE tumbleweed
(bash 5.2) the  output is:
1 4
2 5

I can't reproduce this. I get the correct (bash-4.4) results on bash-5.1
and bash-5.2. There does seem to be a problem with bash-5.0, but it was
corrected in bash-5.1, according to my results.

This is the case for both of your example scripts.

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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