This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don't count on 'trap 0' inside () in shell script
authorAlan Burlison <aburlison@cix.compulink.co.uk>
Thu, 6 Mar 1997 03:28:00 +0000 (16:28 +1300)
committerChip Salzenberg <chip@atlantic.net>
Thu, 6 Mar 1997 16:01:12 +0000 (04:01 +1200)
When building 5.003_91, I noticed that Configure leaves a load of files lying
around in /tmp, for example exp21743c, etc.  These appear to contain lists of
symbols.  A bit of digging reveals that the offender is the perl_exp.SH
script.  This contains a bit of code of the form

        (
        trap "rm -f ...." 0
        ...
        )

I guess that when the sub-shell invoked by the ( ... ) construct exits, the
trap 0 should be taken, and the files removed.  Unfortunately, I have noticed
that on at least 2 systems (UnixWare & Unisys SVR4) this doesn't happen.  The
following patch fixes it.

p5p-msgid: memo.147326@cix.compulink.co.uk

perl_exp.SH

index d964bdf..21165e0 100755 (executable)
@@ -40,11 +40,9 @@ echo "#!" > perl.exp
 
 case "$bincompat3" in
 y*)
-       (
          global=/tmp/exp$$g
          interp=/tmp/exp$$i
          compat3=/tmp/exp$$c
-         trap 'rm -f $global $interp $compat3' 0
          trap 'exit 1' 1 2 3 13 15
          grep '^[A-Za-z]' global.sym | sort >$global
          grep '^[A-Za-z]' interp.sym | sort >$interp
@@ -53,7 +51,7 @@ y*)
          comm -12 $interp $compat3 | sed 's/^/Perl_/' >> perl.exp
          comm -12 $global $compat3 >> perl.exp
          comm -23 $interp $compat3 >> perl.exp
-       )
+         rm -f $global $interp $compat3
        ;;
 *)
        sed -n '/^[A-Za-z]/ s/^/Perl_/p' global.sym interp.sym >> perl.exp