Re: segfault after redefining an alias as a function

Martin D Kealey <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <CAN_U6MUfW6CskGkY5D_uDcoAXc8ubXu6KEt96acW8MeQRQpQiQ@mail.gmail.com>
It's not necessary to delete a function definition before replacing it, but
there is a point to removing an alias before defining a like-named function.

So the keyword you're looking for is "unalias", not "unset".

If for some reason you absolutely must have an alias and a function with
the same name, consider forcing parsing of the function before the alias
command is executed:

 { alias foo=bar; foo() { echo this is not Bar; }

or use a ksh-style function definition:

 alias foo=bar
 function foo { echo this is not Bar; }

(note the lack of () in the latter form)

-Martin

On Wed, 14 Jan 2026, 06:01 Jason Puschnig, <[email protected]> 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
>
> }
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.