helpThe GNU Bourne-Again SHell - Support: sr #109686, Make LINENO work like Zsh's LINENO

 
 

sr #109686: Make LINENO work like Zsh's LINENO

Submitted by:  None
Submitted on:  Fri 17 May 2019 08:02:08 PM UTC  
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Wont Do
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 22 May 2019 03:09:34 PM UTC, comment #1: 

There is an explanation of the issue, which involves how commands are constructed when using a parser generator like bison, in

http://lists.gnu.org/archive/html/bug-bash/2017-03/msg00128.html

Chet Ramey <chet>
Project Administrator
Fri 17 May 2019 08:02:08 PM UTC, original submission:  

echo $(
  echo "hello" \
    "world" \
    "thanks" |
      cat | (
        cat -n
      ) | cat &&
      echo bye
)

Given the above script and PS4='+$BASH_SOURCE:$LINENO> ', running bash -x script gives the following output:

++script:10> echo hello world thanks
++script:11> cat
++script:12> cat -n
++script:13> cat
++script:14> echo bye
+script:9> echo 1 hello world thanks bye
1 hello world thanks bye

The values returned by LINENO are not useful when profiling a script, debugging it, or trying to compute code coverage through a testing framework like Bats.

In comparison, Zsh's LINENO returns the expected values:

+script:2> echo hello world thanks
+script:5> cat
+script:6> cat -n
+script:7> cat
+script:8> echo bye
+script:1> echo 1 hello world thanks bye
1 hello world thanks bye

Could it be possible to make Bash's LINENO variable work like Zsh's one? Or provide a new variable that would?

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-22 chet StatusNone => Wont Do

    Back to the top


    Powered by Savane 3.5