CVS commit: src/bin/sh
"Robert Elz" <[email protected]> Tue, 4 Aug 2026 22:58:28 +0000
| Newsgroups | gmane.os.netbsd.devel.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module Name: src Committed By: kre Date: Tue Aug 4 22:58:28 UTC 2026 Modified Files: src/bin/sh: trap.c trap.h Log Message: /bin/sh - trap.c - new func and avoid lost memory Add run_traps() - which is just dotrap() except that it preserves the state of the stack around the trap executions, so is safe to call with the stack in any state. It will also preserve the state of the growing string at the top of the stack if informed (by giving a non-zero value as its arg) that such a string currently exists. This new function does not exist in SMALL shells. While here, fix an unlikely memory leak - if a shell error (not command error) occurs while processing a trap in dotrap() the copy of the trap string being parsed can be lost. This is irrelevant in non-interactive shells, as the errors which would cause this loss, also cause a non-interactive shell to exit, the lost memory is only lost for a very short time. Interactive shells rarely set traps (except possibly an EXIT trap - for which the memory loss is also immaterial for almost the same reason) at all, and if one were set, and generated a shell error (typically a parsing error) that is only likely to happen once, before being corrected, so the memory loss would be negligible. Nevertheless that is now avoided. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/bin/sh/trap.c cvs rdiff -u -r1.26 -r1.27 src/bin/sh/trap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.