[comp.lang.perl] Why does die with no args exit in eval?

tony@oha.UUCP (Tony Olekshy) (06/29/90)

When I run each of the following through perl 3.0.1.5 patch level 18:

    print "Test 1\n"; eval 'die "me"';	print "> $@";
    print "Test 2\n"; eval 'die ""';	print "> $@";
    print "Test 3\n"; eval 'die';	print "> $@";

I get the following output (and I say there should be a > from each case):

    Test 1
    > me at (eval) line 1.
    Test 2
    Test 3

Am I: 1) missing something, 2) misunderstanding something, or 3) triggering
a bug?

--
Yours etc., Tony Olekshy.               Internet: tony%oha@CS.UAlberta.CA
					  BITNET: tony%oha@UALTAMTS.BITNET
					    uucp: alberta!oha!tony

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (06/29/90)

In article <438@oha.UUCP> tony@oha.UUCP (Tony Olekshy) writes:
: When I run each of the following through perl 3.0.1.5 patch level 18:
: 
:     print "Test 1\n"; eval 'die "me"';	print "> $@";
:     print "Test 2\n"; eval 'die ""';	print "> $@";
:     print "Test 3\n"; eval 'die';	print "> $@";
: 
: I get the following output (and I say there should be a > from each case):
: 
:     Test 1
:     > me at (eval) line 1.
:     Test 2
:     Test 3
: 
: Am I: 1) missing something, 2) misunderstanding something, or 3) triggering
: a bug?

Mmm, let's just say the "die" routine was coded by a stupid programmer
before eval even existed, and he didn't anticipate that die should always
be trapped by eval.  The programmer has been severely reprimanded and promises
never to do it again.  The problem will be fixed in the next patch.  If you
give a null argument to die it will now be as if you said

	die "Died";

And an enclosing eval will trap it.

Larry

logan@rockville.dg.com (James L. Logan) (07/04/90)

In article <8537@jpl-devvax.JPL.NASA.GOV>
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:  
# 
# Mmm, let's just say the "die" routine was coded by a stupid programmer
# before eval even existed, and he didn't anticipate that die should always
# be trapped by eval.  The programmer has been severely reprimanded and promises
# never to do it again.  The problem will be fixed in the next patch.  If you
# give a null argument to die it will now be as if you said

I have a question along the same lines:  why is it that "die;" by
itself does not print anything?  When I throw together a quick,
one-time hack, I don't need the verbosity of  

	die "$MyName: cannot do whatever: $!";

and I don't want the script to die without saying anything at
all.  I just want:  

	script died at - line 20

Is there any reason this shouldn't be the default?

			-Jim
-- 
James Logan                        UUCP: uunet!inpnms!logan
Data General Telecommunications    Inet: logan@rockville.dg.com
2098 Gaither Road                 Phone: (301) 590-3198
Rockville, MD 20850

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (07/04/90)

In article <603@inpnms.ROCKVILLE.DG.COM> logan@rockville.dg.com (James L. Logan) writes:
: In article <8537@jpl-devvax.JPL.NASA.GOV>
: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:  
: # 
: # Mmm, let's just say the "die" routine was coded by a stupid programmer
: # before eval even existed, and he didn't anticipate that die should always
: # be trapped by eval.  The programmer has been severely reprimanded and promises
: # never to do it again.  The problem will be fixed in the next patch.  If you
: # give a null argument to die it will now be as if you said
: 
: I have a question along the same lines:  why is it that "die;" by
: itself does not print anything?  When I throw together a quick,
: one-time hack, I don't need the verbosity of  
: 
: 	die "$MyName: cannot do whatever: $!";
: 
: and I don't want the script to die without saying anything at
: all.  I just want:  
: 
: 	script died at - line 20
: 
: Is there any reason this shouldn't be the default?

That's more or less what I just said was going to happen.

Larry