Eric Kow <[EMAIL PROTECTED]> writes:

> On Tue, Nov 11, 2008 at 23:31:56 +0100, Petr Rockai wrote:
>> Tue Nov 11 23:27:59 CET 2008  Petr Rockai <[EMAIL PROTECTED]>
>>   * Isolate overriding-defaults.sh failures to that test.
>>   
>>   When this test previously failed, it left broken .darcs/defaults around. We
>>   trap exits now and fixup the broken file.
>
> Applying this one (and pleased to learn about trap), thanks!

Note that trap can have... exciting issues.  In particular, a trap's
scope is the entire process -- you cannot have a function-specific trap:

    trap foo EXIT

    f () {
      trap bar EXIT        # WRONG!
    }

    # at this point, foo is the only trap on EXIT
    f
    # during AND AFTER f runs, bar is the only trap on EXIT

Also, named traps are not portable to dash.  Since we explicitly use
bash in the shebang, this second gotcha should not matter.

Also, as always, remember to quote carefully in the trap body -- not a
problem if you just use a function, but consider

    trap 'rm "$tempfile"' EXIT

and remember to take into account exciting cases like the trap
body triggering the trap.

In general, I put simple traps near the top of scripts, and avoid them
otherwise.

_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to