On Tue, Jan 13, 2026 at 21:01:26 +0100, Jason Puschnig wrote:
> Version: GNU bash, version 5.3.9(1)-release (x86_64-pc-linux-gnu)
> 
> Below is the code needed to reproduce this bug. I have been able to
> reproduce this reliably by starting a new interactive shell and entering
> each line manually.
> 
> alias print=printf
> 
> unset print
> 
> print() {
> 
> printf $1
> 
> }

I assume you get the segfault when you CALL this function, not when
you define it, right?

You're creating an infinite recursion here.  You would get the same
result if you simply did

    p() { p "$1"; }

and then called p.  Thus:

hobbit:~$ bash
hobbit:~$ p() { p "$1"; }
hobbit:~$ p
Segmentation fault (core dumped)

In your code, the cause is slightly obscured, because the alias changes
the name of the function that you're defining, from print to printf.
The printf function calls itself recursively with no termination
condition, so calling it will eventually exhaust the stack and cause
a segfault.

Reply via email to