[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Why does ctrl-c behave differently for builtin sleep in a su
From: |
Peng Yu |
Subject: |
[Help-bash] Why does ctrl-c behave differently for builtin sleep in a subshell? |
Date: |
Mon, 17 Dec 2018 13:41:49 -0600 |
Hi,
See the follow code, '(/main_builtin.sh' behaves differently from the
other three scripts upon receiving ctrl-c. This is counter-intuitive.
I'd expect whether a built-in command called the result should be the
same.
How to understand why there is such a difference? Is there an easy
workaround to make the result the same as the other three?
$ ./main.sh
^Cat EXIT
$ ./main_builtin.sh
^Cat EXIT
$ \(/main.sh
^Cat EXIT
$ \(/main_builtin.sh
^C
$ cat main.sh
#!/usr/bin/env bash
trap 'echo at EXIT' EXIT
sleep 10
$ cat main_builtin.sh
#!/usr/bin/env bash
trap 'echo at EXIT' EXIT
enable -f ~/Downloads/bash-4.4/examples/loadables/sleep sleep
sleep 10
$ cat '(/main.sh'
#!/usr/bin/env bash
(
trap 'echo at EXIT' EXIT
sleep 10
)
$ cat '(/main_builtin.sh'
#!/usr/bin/env bash
(
trap 'echo at EXIT' EXIT
enable -f ~/Downloads/bash-4.4/examples/loadables/sleep sleep
sleep 10
)
--
Regards,
Peng
- [Help-bash] Why does ctrl-c behave differently for builtin sleep in a subshell?,
Peng Yu <=