Fix trap -p

Two different bugs completely broke `trap -p`. First bug broke filtering of
functions with trap handlers (`functions -na` prints functions separated by a
comma, not a new line). Second bug broke showing of function definitions for
traps because a refactor renamed only some call sites but references to `$i`
renamed.

These issues were introduced in a6820cbe and appear to have been caught just in
time: no released version is affected (changes made post-3.5.1).
This commit is contained in:
Mahmoud Al-Qudsi 2022-10-24 15:07:29 -05:00
parent 040591bc47
commit c8f92878c3

View file

@ -63,12 +63,12 @@ function trap -d 'Perform an action when the shell receives a signal'
if set -q argv[1]
set names $argv
else
set names (functions -na | string match "__trap_handler_*" | string replace '__trap_handler_' '')
set names (functions -a | string split ',' | string match "__trap_handler_*" | string replace '__trap_handler_' '')
end
for sig in (string upper -- $names | string replace -r '^SIG' '')
if test -n "$sig"
functions __trap_handler_$i
functions __trap_handler_$sig
else
return 1
end