bug-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with N


From: Eduardo Bustamante
Subject: Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status
Date: Thu, 29 Dec 2016 21:39:00 -0600

On Thu, Dec 29, 2016 at 11:20 AM, Steve Amerige <address@hidden> wrote:
> I've posted a question to StackOverflow, but I'm hoping the experts here can
> chime in.
>
> http://stackoverflow.com/questions/41346907/bash-trap-how-to-get-line-number-of-a-subprocess-with-non-zero-status
>
> In essence, I want to know how to get the line number in a function of a
> subprocess that exits with a non-zero status (see line 20 below):
[...]
> Thanks,
> Steve Amerige

First: Try to do better formatting on your emails next time. The code
block is completely unreadable. I had to follow the stackoverflow link
to understand what you were asking.


I'm adding the bug-bash list, since I think this is actually a bug in
the parse_comsub function, or maybe in execute_command_internal. I
haven't been able to figure it out yet. What I do know is that these
two should behave the same:

    address@hidden:~$ cat -n h
         1  #!/bin/bash
         2  shopt -s extdebug
         3  main() {
         4  trap 'echo $LINENO' ERR
         5  (exit 17)
         6  }
         7  main
    address@hidden:~$ ./h
    3

--- vs ---

    address@hidden:~$ cat -n i
         1  #!/bin/bash
         2  shopt -s extdebug
         3  main() {
         4  trap 'echo $LINENO' ERR
         5  `exit 17`
         6  }
         7  main
    address@hidden:~$ ./i
    5

There's no actual reason for these two to be different, and this leads
me to think the behavior you're seeing is a bug somewhere in the
$(...) style command substitution parsing. Perhaps it misses updating
the line_number variable.



reply via email to

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