Re: trap commands in auxiliary scripts

Bruno Haible via Discussion list for automake <[email protected]> Sat, 30 May 2026 00:47:56 +0200
Newsgroups gmane.comp.sysutils.automake.general
Organization GNU
Message-ID <2785121.X9hSmTKtgW@nimes>
Jan Engelhardt wrote:
> >'trap' commands in shell scripts present a dilemma:
> >
> >      trap "rmdir '$lockdir'; exit 1" 1 2 15
> >    we get undefined behaviour if $lockdir contains a single-quote,
> 
> Also worth noting is that $lockdir is/was evaluated at the time of
> the trap setup, and your patch changes the evaluation of $lockdir to
> the time of trap execution.

True. It is essential that the value of $lockdir is not changed once
the 'cleanup' function is defined.

Bruno