# New Ticket Created by "brian d foy" # Please include the string: [perl #130715] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=130715 >
While trying to work around #125757 (using :out makes the Proc object always return zero, I ran into a different problem. I was writing test code to check what a program does in cases where it should exit with a non-zero status. The docs for IO::Handle::close say only: Will close a previously opened filehandle. But other close methods mention using a LEAVE phaser to avoid exceptions. I end up with kludgey code like this to fight against Perl 6 thinking it knows better than I do when something failed: subtest { my $proc = run $*EXECUTABLE, $program, '-k', :err; my $message = try { $proc.err.slurp-rest }; LEAVE { quietly { $proc.err.close } } like $message, rx:i/invalid/, 'Invalid option warns'; is $proc.exitcode, 2, 'exit code'; }, "{$program} exits with false value with unknown switch"; Now, indeed this returned a non-zero exit status. But, it did exactly what I wanted it to. This isn't a failure in my code and it shouldn't be exceptional. Beyond that, there are many programs that use a non-zero exit to mean something that isn't failure. grep(1), for instance, uses 1 to mean no lines matched. And so on. Perl 6 doesn't know these, and I don't think it should make decisions at this level. I wouldn't mind the ability to throw an exception if Proc was told to do that (say, like :raise-exception similar to DBI's RaiseError). But, it's easy enough for the programmer to make this call on their own.