I have following script
#!/bin/bash
exec 5> >(logger -t $0)
BASH_XTRACEFD="5"
set -x
trap _reboot INT
DIALOG_TITLE="This is fancy dialog title"
_reboot() {
echo Exiting
exit
}
dialog --title "${DIALOG_TITLE}" --yesno "Welcome to Dialog" 0 0
However when i do CTRL+C, script is exited without printing anything.
If i remove either set -x
or BASH_XTRACEFD="5"
it will work fine and trap is caught and _reboot function is executed. But if i leave both in (which i need for debugging purposes) - then trap looses all meaning.
Exit code is 141 which is interesting when i exit with CTRL+C.
If i let the script run it's natural course it will exit with 0
However if i remove either of set -x
or BASH_XTRACEFD="5"
and then CTRL+C
i will exit with 55 then.
This for some reason happens only while dialog is on screen. For example if i do
while true; do
sleep 5
done
And then exit with CTRL+C
trap will be executed.
I need help figuring this thing out.
EDIT: Might be worth mentioning that bash version is 5.1.16, running on Alpine 3.16
if [ "$?" = 141 ] ; then echo "Ctrl-C pressed in dialog"; else echo "Dialog exited normally"; fi
immediately after thedialog
line.if
statement is trying to confirm), the bash script won't see the INT signal (unless you press ^C multiple times).