Re: set -e doesn't trigger when command substitutions returns, why?

2025-06-18 Thread Steffen Nurpmeso
Greg Wooledge wrote in <20250618140055.gf28...@wooledge.org>: |On Wed, Jun 18, 2025 at 04:57:01 +0300, nkkralev--- via Bug reports \ |for the GNU Bourne Again SHell wrote: |> to occur.]#test1 |> /bin/bash -c 'set -e ; /bin/echo $(ls /doesnt_exist) ; echo print1' |> #and the stdout/stderr disp

Re: set -e doesn't trigger when command substitutions returns, why?

2025-06-18 Thread Chet Ramey
On 6/17/25 9:57 PM, nkkralev--- via Bug reports for the GNU Bourne Again SHell wrote: When we use set -e, or pass -e to bash itself, -e does process status code checks as written in the bash man page.With some testing I think I found a few corner cases which I am not sure if they are bugs or

Re: IGNOREEOF is ineffective when holds a big integer

2025-06-18 Thread Greg Wooledge
On Wed, Jun 18, 2025 at 03:59:52 +, shynur . wrote: > Martin: > > In variables.c at line 6243 we have > > eof_encountered_limit = (*temp && all_digits (temp)) ? atoi (temp) : 10; This use of atoi is unique to the IGNOREEOF variable and does not occur in most other places in bash. hobbit:/usr

Re: set -e doesn't trigger when command substitutions returns, why?

2025-06-18 Thread Greg Wooledge
On Wed, Jun 18, 2025 at 04:57:01 +0300, nkkralev--- via Bug reports for the GNU Bourne Again SHell wrote: > to occur.]#test1 > /bin/bash -c 'set -e ; /bin/echo $(ls /doesnt_exist) ; echo print1' > #and the stdout/stderr displayed is: > ls: cannot access '/doesnt_exist': No such file or directorypr

set -e doesn't trigger when command substitutions returns, why?

2025-06-18 Thread nkkralev--- via Bug reports for the GNU Bourne Again SHell
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-Smvct5/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security uname o

Re: IGNOREEOF is ineffective when holds a big integer

2025-06-18 Thread Chet Ramey
On 6/17/25 10:31 PM, shynur . wrote: ``` INT_MAX=`echo \`printf '%u' -1\`/2 | bc` IGNOREEOF=INT_MAX # Then I typed C-d, bash exited... ``` ``` IGNOREEOF=127 # C-d, C-d, C-d, ... ``` Why doesn’t the first piece of code work as expected? Because it's not the right way to determine INT_MAX, and

Re: set -e doesn't trigger when command substitutions returns, why?

2025-06-18 Thread microsuxx
u can try trap '(( $? )) && exit 2' debug On Wed, Jun 18, 2025, 5:05 PM Steffen Nurpmeso wrote: > Greg Wooledge wrote in > <20250618140055.gf28...@wooledge.org>: > |On Wed, Jun 18, 2025 at 04:57:01 +0300, nkkralev--- via Bug reports \ > |for the GNU Bourne Again SHell wrote: > |> to occur.]

Re: Segmentation fault and code execution.

2025-06-18 Thread microsuxx
try x() first then alias On Wed, Jun 18, 2025, 7:30 PM Stan Marsh wrote: > This is a "Doctor, it hurts when I do this" type thing. > > The short answer is that alias substitution occurs very early, so when you > type: > > alias x='this and that' > x() { ... } > > you are for all practica

Re: Incomplete cleanup in Bash with malformed heredoc in pipeline

2025-06-18 Thread Martin D Kealey
On Thu, 19 Jun 2025 at 07:37, Alvaro Falagan wrote: > Bash does not clean up all its internal memory and leaves at least one file > descriptor (`/dev/pts/0`, fd 255) open at exit. Why would it be a problem if memory is still allocated or filedescriptors are still open at exit? Memory pages and

Re: Segmentation fault and code execution.

2025-06-18 Thread microsuxx
u first define func then u use aliases On Wed, Jun 18, 2025, 10:05 PM Alberto Millán wrote: > First of all, I'd like to thank you for your responses. > > Okay, now I understand a little better what's going on with recursion. > > In most cases, I can now see what's wrong, but there's one specific

Re: Segmentation fault and code execution.

2025-06-18 Thread Chet Ramey
On 6/18/25 4:05 PM, Alberto Millán wrote: First of all, I'd like to thank you for your responses. Okay, now I understand a little better what's going on with recursion. In most cases, I can now see what's wrong, but there's one specific case where I can't quite figure out what's wrong. bash

Segmentation fault and code execution.

2025-06-18 Thread Stan Marsh
This is a "Doctor, it hurts when I do this" type thing. The short answer is that alias substitution occurs very early, so when you type: alias x='this and that' x() { ... } you are for all practical purposes, typing: 'this and that'() { ... } At which point, anything can happen. I

Re: Segmentation fault and code execution.

2025-06-18 Thread Chet Ramey
On 6/18/25 11:38 AM, Alberto Millán wrote: Bash Version: 5.2 Patch Level: 37 Release Status: release Description: When I define an alias and a function with the same name, I experience abnormal behavior. It seems to be especially dangerous when using a colon. I think there is a misu

Re: set -e doesn't trigger when command substitutions returns, why?

2025-06-18 Thread nkkralev--- via Bug reports for the GNU Bourne Again SHell
``` u can try trap '(( $? )) && exit 2' debug ``` I mean, I know that $? doesn't detect the tests I posted in my first email, even if we do bash -e -c 'echo $(exit 1) ; echo survived' We see that survived is printed, this trap snippet you wrote here seems to duplicate what set -e does? I repea

Segmentation fault and code execution.

2025-06-18 Thread Alberto Millán
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 uname output: Linux ALBERTO 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x8

Re: Segmentation fault and code execution.

2025-06-18 Thread Alberto Millán
Oh, okay. Now everything is much clearer. Seeing this, I can understand, for example, why if I run this twice, the first time I get the output of the 'id' command and the second time the output of the 'pwd' command. alias id=pwd;id # id output. alias id=pwd;id # pwd output. Thank you again fo

Re: Segmentation fault and code execution.

2025-06-18 Thread Eduardo Bustamante
On Wed, Jun 18, 2025 at 9:31 AM Alberto Millán wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -g -O2 > uname output: Linux ALBERTO 6.6.87.2-microsoft-standard-WSL2 #1 SMP > PREEMPT_DYNAMIC Thu Ju

Re: Segmentation fault and code execution.

2025-06-18 Thread Alberto Millán
First of all, I'd like to thank you for your responses. Okay, now I understand a little better what's going on with recursion. In most cases, I can now see what's wrong, but there's one specific case where I can't quite figure out what's wrong. bash -ic $'alias x=:\nx(){ id;};x' # This case cra