Hi,

Here is the behavior of a normal bash script. If I type ctrl-c, it
will terminate the program. But it will also trigger the EXIT trap
which print "1".

---------------
$ cat script.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

function cmd {
#echo $1
trap "echo $1" EXIT
}

cmd 1
sleep 5
$ ./script.sh
^C1
---------------

But when I run it with parallel, the signals will not be triggered by
ctrl-c. Should this be considered as a bug?

---------------
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

code=$(
cat <<'EOF'
function cmd {
#echo $1
trap "echo $1" EXIT
}
EOF
)

set -v
seq 12 | parallel "$code; cmd {}; sleep 5"
$ ./main.sh
seq 12 | parallel "$code; cmd {}; sleep 5"
^C


-- 
Regards,
Peng

Reply via email to