Date: Thu, 11 Sep 2025 23:02:16 +0200 From: Mike Jonkmans <bash...@jonkmans.nl> Message-ID: <20250911210216.ga164...@jonkmans.nl>
| 1) BASH_COMMAND is foo's 'return 1'. Shouldn't that be 'foo'? That I will leave for someone else. | There is no error in 'return 1' per se. Not relevant, the ERR trap, according to the bash man page: If a sigspec is ERR, action is executed whenever a pipeline (which may consist of a single simple command), a list, or a compound command returns a non-zero exit status, subject to the following conditions. [None of those are relevant here]. The pipeline "foo" returned a non-zero exit status, hence the ERR trap was invoked. | According to the trace, foo is not being run. It returned already. But perhaps (and answering the first point) the actual ERR trap came from the "return 1" in foo, but is executed after that command has completed (returning a non-zero status - but also exiting from foo) and is invoked because the trap exists in mymain() where we now are (which would all be a bit convoluted, but never mind). The rest I also leave for someone else to comment upon. kre