New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
localizing $? loses exit status from die() #7366
Comments
From cjwatson@debian.orgCreated by cjwatson@debian.org $ perl -e 'die "hello";'; echo $? $ perl -e 'local die() is specified in perlfunc as follows: Outside an "eval", prints the value of LIST to "STDERR" and exits with ... and $? is specified in perlvar as follows: Inside an "END" subroutine $? contains the value that is going to be However, the localization above is not within an END block, and I don't It seems useful to be able to localize $? in order to write subs that If the current behaviour is really desired, then it would be nice to (Ian Jackson discovered this; I'm just passing it on.) Perl Info
|
From @smpeters
Actually, local isn't the only cause. Certain modules seem to help this
|
The RT System itself - Status changed from 'new' to 'open' |
From @iabynOn Sat, Apr 23, 2005 at 02:17:52PM -0000, Steve Peters via RT wrote:
Er no; with Deparse, the code is never executed, so the die never happens. -- |
From @HugmeirOn Tue Jun 15 16:19:35 2004, cjwatson@debian.org wrote:
PATH=/home/cjwatson/bin:/usr/lib/surfraw:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/sbin:/sbin
This is still present in 5.14.2 and blead. But, personally, I consider I think these two snippets show that local() is working as expected: $ perl -e 'local |
From @nwc10On Mon, Apr 30, 2012 at 01:01:13AM -0700, Brian Fraser via RT wrote:
The bug is in die, not in local. local is working fine, die is not. die is The fact that local is a dynamic scope results in the potential for messy $ perl -e 'sub elsewhere {use autodie; open my $fh, "/foo"} elsewhere()' whereas if I localise $? $ perl -e 'sub elsewhere {use autodie; open my the exit code is zero, which is wrong. Nicholas Clark |
From @ikegamiOn Mon, Apr 30, 2012 at 4:01 AM, Brian Fraser via RT <
die() is within scope of the local
|
Migrated from rt.perl.org#30296 (status was 'open')
Searchable as RT30296$
The text was updated successfully, but these errors were encountered: