helpThe GNU Bourne-Again SHell - Support: sr #110552, 'trap -p' inside function does not...


sr #110552: 'trap -p' inside function does not print all enabled signals

Submitter:  Dominik Kummer <domson>
Submitted:  Wed 20 Oct 2021 10:55:18 PM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Works For Me
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Fri 22 Oct 2021 03:14:17 PM UTC, comment #2: 

I see, I just did not see the obvious. Now it also works for me! Next time I'll surely consult stackexchange first, cause I think bash bugs are pretty unusual. Thanks though!

Dominik Kummer <domson>
Fri 22 Oct 2021 01:20:14 PM UTC, comment #1: 

You have to enable that behavior.

This is from the man page. The info manual contains similar language.

"All other aspects of the shell execution environment are identical  be-
       tween  a  function  and its caller with these exceptions: the DEBUG and
       RETURN traps (see the description  of  the  trap  builtin  under  SHELL
       BUILTIN  COMMANDS below) are not inherited unless the function has been
       given the trace attribute (see the description of the  declare  builtin
       below)  or  the -o functrace shell option has been enabled with the set
       builtin (in which case all  functions  inherit  the  DEBUG  and  RETURN
       traps),  and the ERR trap is not inherited unless the -o errtrace shell
       option has been enabled."

Chet Ramey <chet>
Project Administrator
Wed 20 Oct 2021 10:55:18 PM UTC, original submission:  

The signals ERR and RETURN are not printed inside a function scope but outside. I need to define a function that writes several filtered environments (declare/shopt/trap) into a file, but ERR and RETURN are always omitted.

Dominik Kummer <domson>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by domson (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-10-22 chet StatusNone Works For Me

    Back to the top

    Powered by Savane 3.9