On 3/22/24 2:02 AM, Gioele Barabucci wrote:
For various reasons. First of all, because it confuses users (there are various bug reports in Debian for this specific issue).More technically, because non-builtin commands are treated differently, for example /bin/echo (from <https://bugs.debian.org/423207>):There's been a fair amount of (inconclusive) discussion on the POSIX mailing list about this issue at various points, but not enough reason to change the way bash has always behaved.Dear Chet, thanks you for your reply. Do you have a link or two to these discussions that I can add to the Debian bug reports to explain why they will be marked as "wontfix"?
The one I can find looking quickly is https://www.austingroupbugs.net/view.php?id=789; that one lasted for years.
which is a discussion about `pipefail' but includes comments about setting SIGPIPE to SIG_IGN with trap if you don't want it to affect the exit status. There was also a May, 2016 discussion, but I don't know where the austin- group mail archives are kept. That one was inconclusive, but did note that there are a number of pieces of state that can cause differing behavior when a builtin is executed (e.g., resource limits). If you want to insulate a script against this, there are various ways to discover whether or not a utility is a builtin (e.g., type) and to make sure you always run something external (e.g., full pathnames or enable to disable the builtin).
For example, there is plenty of code that expects the shell to exit when you hit it with, say, a SIGHUP while it's executing a builtin, or if you hit a non-interactive shell with a SIGTERM during a builtin, because that's how shells have always behaved.I'd argue (but I assume it has already been done in the aforementioned discussions) that the SIGPIPE comes from a command being run in a pipeline provided by the user, while these other signals come from an "external" source (the user? other programs?).
There's no real difference. The shell gets a signal and either handles it or does not. From the script's perspective, it doesn't matter what originates it. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature