[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ERR trap inheritance in command substitution
From: |
Stefan Götz |
Subject: |
ERR trap inheritance in command substitution |
Date: |
Fri, 08 Jan 2010 18:50:43 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
Hi!
It seems that in bash version 4.0.33(1)-release (i486-pc-linux-gnu) (from Ubuntu
9.04), ERR traps are not inherited by functions that are called via command
substitution. I expected inheritance to apply in this case since the
documentation of 'set -E' promises inheritance of the ERR trap for subshell
contexts. The script below illustrates this behavior as the trap action
err_handler() is not called.
Is this behaviour intended? Even if so, I'd like to say that I would find ERR
trap inheritance for command substitution extremely useful :-)
Cheers,
Stefan
#!/bin/bash
err_handler() {
echo "THERE WAS AN ERROR"
}
set -E
trap 'err_handler' ERR
myfunc() {
false # fails to cause an ERR trap
true
}
FOO=$(myfunc)
exit 0
signature.asc
Description: OpenPGP digital signature
- ERR trap inheritance in command substitution,
Stefan Götz <=