Let's assume I have the following function:
#!/usr/bin/env bash
f(){
trap 'printf "\nAborting\n"; return 1' SIGINT
sleep 10
return 0
}
If I run f
and wait those 10 seconds and then do
$ echo $?
> 0
That's expected. But if I run f
and hit Ctrl+c
, the function f
is aborted, but
$ echo $?
> 0
instead of 1
. I assume I'm not trapping properly, but don't how to fix it.