#!/bin/sh --
for set_trap_sig in HUP INT QUIT ALRM TERM; do
trap -- '
trap -- - '"${set_trap_sig:?}"' EXIT || exit "$?"
kill -s '"${set_trap_sig:?}"' -- "$$" || exit "$?"' "$set_trap_sig"
done
sleep 15 || exit "$?"
Here's what happens when I send SIGINT to the script
user@hostname:/tmp$ ./script.sh
^C./script.sh: 3: ./script.sh: Syntax error: EOF in backquote substitution
This issue seems specific to dash. On ash, bash and ksh93 I do not get this error. This is particularly weird because my script does not even contain the backquote character.
If I remove the double quotes on the trailing $?
on line 5 the error goes away.
Am I doing something stupid or is dash misbehaving? Please, no comments about the level of error-checking in my scripts.
We have now established that this a very serious bug that affects even modern versions of Ubuntu and Debian. Does anyone know of a workaround?
dash
. – Kusalananda Apr 20 '19 at 06:58