Le 25/06/2026 à 00:36, Gregory Heytings écrivait :
Is this better thantrap_append () { trap "$(printf "%s\n$1" "$(trap -P "$2")")" "$2"; } trap_prepend () { trap "$(printf "$1\n%s" "$(trap -P "$2")")" "$2"; }
While effective, these functions rely on subshells for serialization and re-parsing, introducing unnecessary overhead and reduced readability due to the density required for quoting and string manipulation.
A native defer builtin provides a standard interface without these dependencies, eliminating subshells and "manual" trap string handling. As of now, defer exists as a loadable builtin as a thin-surface tech demonstrator, acknowledging the disadvantage of needing to compile and load the module. If adopted, integration as a core builtin would offer a robust and efficient standard for LIFO cleanup operations.
-- Léa Gris
