Skip Menu |

This queue is for tickets about the Net-OpenSSH CPAN distribution.

Report information
The Basics
Id: 129350
Status: resolved
Priority: 0/
Queue: Net-OpenSSH

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.78
Fixed in: (no value)



Subject: disconnect clobbers $?
Calling disconnect may overwrite the previous value of $?. A test script: #!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; use Test::More 'no_plan'; my $host = "localhost:8022"; # please adjust my $ssh = Net::OpenSSH->new($host); $ssh->error and die $ssh->error; $? = 1; { #local $?; # uncomment to workaround the problem $ssh->disconnect; } is $?, 1, '$? was preserved'; __END__ Looking at the Net::OpenSSH code it seems that DESTROY would have the same problem, but it is explicitly localizing $? (and other variables) before calling _disconnect(). I wonder if the localizing should be always done --- or are there use cases where a user might be interested in these values? Alternative would be to document this behaviour. I stumbled over the problem when I called disconnect() explicitly in another object's DESTROY block, and was wondering why the exit code wasn't as expected ( https://github.com/eserte/Doit/commit/352489c9cc7e0f3fe942a3041304ee21353368a7 )