Re: A defer command as a bash loadable builtin
Oğuz <[email protected]> Thu, 25 Jun 2026 15:21:09 +0300
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <CAH7i3LpE0CL7nvfh5knaYFeQ5pEGKcyD+vx3CDhsRTDiZH9Ruw@mail.gmail.com> |
25 Haziran 2026 Per=C5=9Fembe tarihinde L=C3=A9a Gris <[email protected]= t> yazd=C4=B1: > Le 25/06/2026 =C3=A0 00:36, Gregory Heytings =C3=A9crivait=E2=80=AF: > >> Is this better than >> >> trap_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. > I believe you can avoid subshells using no-fork command substitutions here. But I recall there was a feature request on this list for a `defer' command, so maybe there's an audience for this... Anyway, thanks for sharing it with us --=20 O=C4=9Fuz