Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
open my $fh,"gunzip -c $input_file |" or die "$!";
The trouble is this: if the gunzip returned non-zero (e.g., if the input file does not exist) I don't have a way to detect this. Can you suggest a way to have open fail when the pipe command has non-zero result code? Is this a bash thing, like
set -o pipefailI can (and do) check for the existence of the input file, but was wondering if there is a better way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: detecting non-zero exit code when opening from a pipe
by ikegami (Patriarch) on Oct 21, 2010 at 18:32 UTC | |
by Anonymous Monk on Oct 21, 2010 at 21:28 UTC | |
by ikegami (Patriarch) on Oct 21, 2010 at 22:49 UTC | |
|
Re: detecting non-zero exit code when opening from a pipe
by BrowserUk (Patriarch) on Oct 22, 2010 at 00:30 UTC | |
|
Re: detecting non-zero exit code when opening from a pipe
by aquarium (Curate) on Oct 21, 2010 at 23:16 UTC |