On Monday, September 1st, 2025 at 2:57 AM, Martin D Kealey <[email protected]> wrote: > - Importantly, foreground built-in commands don't run in their own > process; they're handled by the shell process itself. > > This last point is why the main shell process gets killed when echo > attempts to write to a broken pipe.
Thank you for the explanation, I get now why that happens. --- > What else should happen instead? I would expect Bash to interrupt the command line and return to prompting me for further commands, until I explicitly ask for it to exit. > Are you saying an interactive shell should handle signals gracefully > when it's executing builtin commands? FWIW, both ksh and zsh handle this gracefully. The same command line makes neither of them crash, and I verified that both of them have an echo builtin. I understand the special situation this is, and I really appreciate the explanation. However, I don't understand why that behavior _should be_ what happens. I suppose every software bug has an underlying technical explanation, but they still get fixed if they hinder the use of the software. In my case, I first encountered this problem when I mistyped a command. I was very surprised to see my terminal window suddenly popping out of existence. Usually, when I mistype a command, bash warns me about it, interrupts the whole process chain, and prompts me for another command to give me a chance to fix my mistake. To have my terminal forcibly close under certain unfortunate circumstances significantly hinders my work. If at all possible, I would really like bash to at least not exit early, similarly to ksh and zsh.
