Reported by an AI tool in the name of MichaĆ Majchrowicz.
Based on the idea from Autoconf commit
416b8f50c9bd4e38f9bc48b946505d2a18f6b1fd:
Use a shell function to avoid quoting hassles inside a 'trap' argument.
* lib/compile (cleanup): New function.
(trap): Use it.
* lib/depcomp (cleanup): New function.
(trap): Use it.
* lib/ylwrap (origdirname): New variable.
(cleanup): New function.
(do_exit): Use it.
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
-trap "rmdir '$lockdir'; exit 1" 1 2 15
+cleanup () {
+ rmdir "$lockdir"
+}
+trap "cleanup; exit 1" 1 2 15
# Run the compile.
"$@"
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
- trap "
+ cleanup () {
echo '$0: caught signal, cleaning up...' >&2
- rmdir '$lockdir'
- exit 1
- " 1 2 13 15
+ rmdir "$lockdir"
+ }
+ trap "cleanup; exit 1" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
*[\\/]*) prog=`pwd`/$prog ;;
esac
+origdirname=`pwd`
dirname=ylwrap$$
-do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
+cleanup () {
+ cd "$origdirname" && rm -rf $dirname > /dev/null 2>&1
+}
+do_exit='cleanup; (exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13