bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A defer command as a bash loadable builtin


From: Andreas Schwab
Subject: Re: A defer command as a bash loadable builtin
Date: Thu, 25 Jun 2026 14:10:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Jun 25 2026, Léa Gris wrote:

> Le 25/06/2026 à 00:36, Gregory Heytings écrivait :
>> 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.

trap_append () { trap "$(trap -P "$2")
$1" "$2"; }
trap_prepend () { trap "$1
$(trap -P "$2")" "$2"; }

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]