Hi, I'm forwarding a minor issue originally reported in
<https://bugs.debian.org/929178>.
If a function does not set a trap, `trap` will output the command set by
the caller. This is just a cosmetic issue, the right trap will be run at
runtime.
To reproduce this issue:
#!/bin/bash
f1() { echo "trap in f1: $(trap)" >&2 ; }
f2() {
echo "trap in f2 (initial): $(trap)" >&2
trap "/bin/echo f2" EXIT
echo "trap in f2 (final): $(trap)" >&2
}
trap "/bin/echo main" EXIT
echo "f1 output: <$(f1)>"
echo "f2 output: <$(f2)>"
Output:
trap in f1: trap -- '/bin/echo main' EXIT
f1 output: <>
trap in f2 (initial): trap -- '/bin/echo main' EXIT
trap in f2 (final): trap -- '/bin/echo f2' EXIT
f2 output: <f2>
main
Regards,
--
Gioele Barabucci