Re: Unexpected $BASH_COMMAND after error in subshell

2025-02-26 Thread microsuxx
++bugfixes++ On Wed, Feb 26, 2025, 3:15 PM Chet Ramey wrote: > On 2/23/25 12:20 PM, Max Bowsher wrote: > > > Bash Version: 5.2 > > Patch Level: 37 > > Release Status: release > > > > Description: > > > > When using $BASH_COMMAND in an EXIT trap t

Re: Unexpected $BASH_COMMAND after error in subshell

2025-02-26 Thread Chet Ramey
On 2/23/25 12:20 PM, Max Bowsher wrote: Bash Version: 5.2 Patch Level: 37 Release Status: release Description: When using $BASH_COMMAND in an EXIT trap to tell the user what failed, I came across a problem where errors in subshells would instead implicate the command immediately before the

Unexpected $BASH_COMMAND after error in subshell

2025-02-23 Thread Max Bowsher
: x86_64-pc-linux-gnu Bash Version: 5.2 Patch Level: 37 Release Status: release Description: When using $BASH_COMMAND in an EXIT trap to tell the user what failed, I came across a problem where errors in subshells would instead implicate the command immediately before the subshell, instead of the

Re: [PATCH] consistent BASH_COMMAND, DEBUG trap, xtrace order

2023-08-28 Thread Chet Ramey
On 8/25/23 10:40 PM, Grisha Levit wrote: There is some inconsistency betweeen various command types in the order of (1) setting the value used for BASH_COMMAND (2) running the DEBUG trap and checking its return value and (3) printing the PS4 string. Thanks for the report and patch. -- ``The

[PATCH] consistent BASH_COMMAND, DEBUG trap, xtrace order

2023-08-25 Thread Grisha Levit
There is some inconsistency betweeen various command types in the order of (1) setting the value used for BASH_COMMAND (2) running the DEBUG trap and checking its return value and (3) printing the PS4 string. While simple, arithmetic, and conditional commands follow the order above, `for

Re: BASH_COMMAND should be set before PS0

2022-03-21 Thread Chet Ramey
before the command is   executed.     BASH_COMMAND:   The command currently being executed or about to be executed, unless   the shell is executing a command as the result of a trap, in which   case it is the command executing at the time of the trap. If   BASH_COMMAND is unset

Re: BASH_COMMAND should be set before PS0

2022-03-19 Thread Alex fxmbsw7 Ratchev
a small cosmetic workaround fix trap 'cmd=$BASH_COMMAND' DEBUG PS1='$cmd' On Sat, Mar 19, 2022 at 6:12 PM Taqras via Bug reports for the GNU Bourne Again SHell wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 >

BASH_COMMAND should be set before PS0

2022-03-19 Thread Taqras via Bug reports for the GNU Bourne Again SHell
Patch Level: 16 Release Status: release Description:     PS0:   The value of this parameter is expanded like PS1 and displayed by   interactive shells after reading a command and before the command is   executed.     BASH_COMMAND:   The command currently being executed or about to be execu

Re: BASH_COMMAND does not expand correctly in subshells inside traps.

2021-11-05 Thread Emanuele Torre
OURCE:$LINENO] $BASH_COMMAND?" _ ;} trap 'debug_prompt "$_"' DEBUG or even like so (to avoid issues with `unset -f debug_prompt'): trap ' debug_prompt () { read -p "[$BASH_SOURCE:$LINENO] $BASH_COMMAND?" _ ;} debug_prompt "$_" ' DEBUG

Re: BASH_COMMAND does not expand correctly in subshells inside traps.

2021-11-05 Thread Alex fxmbsw7 Ratchev
ease > > > > Description: > >BASH_COMMAND does not expand to the expected value when used in a > >subshell inside a trap. > > This is a variant of > > https://lists.gnu.org/archive/html/help-bash/2021-10/msg00269.html > > In this case, as explained in the above me

Re: BASH_COMMAND does not expand correctly in subshells inside traps.

2021-11-05 Thread Chet Ramey
On 11/4/21 5:49 PM, Emanuele Torre wrote: Bash Version: 5.1 Patch Level: 8 Release Status: release Description: BASH_COMMAND does not expand to the expected value when used in a subshell inside a trap. This is a variant of https://lists.gnu.org/archive/html/help-bash/2021-10/msg00269

Re: BASH_COMMAND does not expand correctly in subshells inside traps.

2021-11-05 Thread Emanuele Torre
> $ cat test1 > trap 'echo "$BASH_COMMAND"' DEBUG > echo hello > $ cat test2 > trap '(echo "$BASH_COMMAND")' DEBUG > echo hey > bash And the content of the test files was really: $ cat test1 trap 'echo "$BAS

Re: BASH_COMMAND does not expand correctly in subshells inside traps.

2021-11-04 Thread Emanuele Torre
> And noticed that $BASH_COMMAND always expanded to: > > read -p "[...:...] $BASH_COMMAND? > > where the ...:... is the expanded value of $BASH_SOURCE:$LINENO. Err, sorry about that. I misremembered. It is actually expanding to read -p "[$BASH_SOURCE:$LINE

BASH_COMMAND does not expand correctly in subshells inside traps.

2021-11-04 Thread Emanuele Torre
; -DSYS_BASHRC='/etc/bash.bashrc' -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS uname output: Linux t420 5.10.75-1-lts #1 SMP Wed, 20 Oct 2021 11:02:09 + x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.1 Patch Level: 8 Release Stat

Re: BASH_COMMAND is incorrect when working with subshells and error traps

2012-08-22 Thread Chet Ramey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/22/12 3:35 PM, Mike Frysinger wrote: > On Wednesday 22 August 2012 12:30:11 Mike Frysinger wrote: >> consider this simple code: >> >> $ cat test.sh >> #!/bin/bash >> trap 'echo $BASH_COMMAND; exit 1

Re: BASH_COMMAND is incorrect when working with subshells and error traps

2012-08-22 Thread Mike Frysinger
On Wednesday 22 August 2012 12:30:11 Mike Frysinger wrote: > consider this simple code: > > $ cat test.sh > #!/bin/bash > trap 'echo $BASH_COMMAND; exit 1' ERR > set -e > true > (false) > true > > when run, we see: > $ ./test.sh > true 1 err,

BASH_COMMAND is incorrect when working with subshells and error traps

2012-08-22 Thread Mike Frysinger
consider this simple code: $ cat test.sh #!/bin/bash trap 'echo $BASH_COMMAND; exit 1' ERR set -e true (false) true when run, we see: $ ./test.sh true 1 this can be confusing when utilized with automatic backtraces :( even when using errtrace and debugtrace, BASH_COMMAND is incor

BASH_COMMAND

2006-08-25 Thread Brian J. Murrell
Is there something I am mis-understanding about $BASH_COMMAND? The manpage says: BASH_COMMAND The command currently being executed or about to be executed, unless the shell is executing a command as the result of a trap, in which case it is the