in reply to Re: best practices for checking system return values for piped commands?
in thread best practices for checking system return values for piped commands?
I second the use of bash-es PIPESTATUS, I've used it in code like this:
my %cmds = ( 'bash' => '/usr/local/bin/bash', 'gzip' => '/usr/bin/gzip', 'lzop' => '/usr/bin/lzop', 'wc' => '/usr/bin/wc' ); my @zip_results = `$cmds{'bash'} -c '$cmds{$compress} -dc $file | $cmds{'wc'} -c ; echo \${PIPESTATUS\@}'`;The last line of @zip_results has the status of both the 'compress' command and the 'wc' command.
In Section
Seekers of Perl Wisdom