On 10/27/22 11:33 AM, Erik Adelbert wrote:
Bash Version: 5.2
Patch Level: 2
Release Status: release
Description:
We have found that
[https://www.gnu.org/software/bash/manual/bash.html#Shell-Functions shell
function] _declarations_:
0 do not emit trace output
0 do not call DEBUG trap
0 modify $?
Unless we have missed the related documentation,
This is from the man page for `set':
-x After expanding each simple command, for command, case
command, select command, or arithmetic for command, dis-
play the expanded value of PS4, followed by the command
and its expanded arguments or associated word list.
No shell includes function definitions in `set -x' output, and I don't
see how doing so adds value.
And for `trap':
If a sigspec is EXIT (0) the command arg is executed on exit
from the shell. If a sigspec is DEBUG, the command arg is exe-
cuted before every simple command, for command, case command,
select command, every arithmetic for command, and before the
first command executes in a shell function (see SHELL GRAMMAR
above). Refer to the description of the extdebug option to the
shopt builtin for details of its effect on the DEBUG trap. If a
sigspec is RETURN, the command arg is executed each time a shell
function or a script executed with the . or source builtins fin-
ishes executing.
A function definition is a command itself. This is from the man page in
the `Shell Function Definitions' section:
"The exit status of a function definition is zero
unless a syntax error occurs or a readonly function with the
same name already exists."
we believe the current semantic to be at least unclear and would like to
see either:
0 the DEBUG trap called _before_ any function declaration (preferred)
While calling the DEBUG trap before certain compound commands has value, I
don't think that function definition commands rise to that level.
0 or function declarations preserving $? as they are not commands appearing in
trace and DEBUG (has cons)
They are required to exit with status 0.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05_01
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/