mainThe GNU Bourne-Again SHell - Support: sr #111015, feature request: showing line and...

 
 

sr #111015: feature request: showing line and source file with -vx arguments

Submitter:  None
Submitted:  Wed 31 Jan 2024 12:52:23 PM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  1 - Wish Status:  Works For Me
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 31 Jan 2024 04:42:02 PM UTC, comment #5: 

OK. It works as documented for me.

You might want a trailing space in $PS4.

Chet Ramey <chet>
Group administrator
Wed 31 Jan 2024 04:37:41 PM UTC, comment #4: 

I tested your PS4 idea in the following /tmp/trychet.bash (Linux/Debian)

#!/bin/bash -vx
export PS4='dolzero=$0 lineno=$LINENO bash_source=$BASH_SOURCE bash_lineno=$BASH_LINENO'
printf 'dollarstar=%s\n' $*


and tried to apply your idea in https://github.com/RefPerSys/RefPerSys/blob/master/do-configure-refpersys.bash

(which still don't work correctly).

Thanks for reading.

Basile Starynkevitch             <basile@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/
See/voir:   https://github.com/RefPerSys/RefPerSys

Anonymous
Wed 31 Jan 2024 04:30:40 PM UTC, comment #3: 


> Does the PS1 trick work in a non-interactive script?


I said PS4, and there's no script attached?

Chet Ramey <chet>
Group administrator
Wed 31 Jan 2024 03:59:04 PM UTC, comment #2: 

Does the PS1 trick work in a non-interactive script?

The attached trychet.bash script don't show the expanded lineno thru -vx flags.

Thanks for your comments

Basile Starynkevitch             <basile@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/
See/voir:   https://github.com/RefPerSys/RefPerSys

Anonymous
Wed 31 Jan 2024 03:05:59 PM UTC, comment #1: 

You can already do this by setting PS4. Look at the $0, LINENO, BASH_SOURCE, and BASH_LINENO variables for the information you'd like to see in $PS4.

Chet Ramey <chet>
Group administrator
Wed 31 Jan 2024 12:52:23 PM UTC, original submission:  

When GNU bash (in my case 5.2.21 on Debian/Triskie x86-64) is started in a script starting #!/bin/bash -vx it would be worthwhile to display (when possible) the line number and the file path of the currently expanded/executed command (or to give some shopt option for this).

This would be useful to debug configuration like scripts or complex GNU make actions.

As an example, in the RefPerSys (GPLv3+ licensed) inference engine project (see http://refpersys.org/ and GPL code for Linux on https://github.com/RefPerSys/RefPerSys/ the buggy GNU bash script (the bug is mine, not in GNU bash) https://github.com/RefPerSys/RefPerSys/blob/ec3f02c84b3e45432493b434d96000cf0c241f20/do-configure-refpersys.bash is difficult to debug because I don't easily understand what command is expanded and why and how.

Thanks for reading.

Basile Starynkevitch             <basile@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/
See/voir:   https://github.com/RefPerSys/RefPerSys


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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-31 chet StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code