bug-bash
[Top][All Lists]
Advanced

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

Re: Segfault when running alias if PROMPT_COMMAND is not empty


From: Chet Ramey
Subject: Re: Segfault when running alias if PROMPT_COMMAND is not empty
Date: Mon, 7 Jul 2025 09:43:42 -0400
User-agent: Mozilla Thunderbird

On 7/5/25 2:57 PM, Carl Johnson wrote:

Bash Version: 5.3
Patch Level: 0
Release Status: release

Description:
When alias definition contains the 'unalias' builtin with the alias's
name as its argument with a newline anywhere after the builtin
invocation, running the alias when PROMPT_COMMAND is not empty causes
a segmentation fault.

Repeat-By:
Start an bash shell, run the following code:
```bash
PROMPT_COMMAND=:
alias a=$'unalias a\n'
a
```
The result is a segmentation fault.

Thanks for the report. In the general case, evaluating the value of a shell
variable as a command should save and restore the parser state. In this
edge case, though, it's not necessary because PROMPT_COMMAND is only
evaluated before parsing a command. The attached patch should fix it.

Chet


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: prompt-command-unalias.patch
Description: Text document

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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