pjf / ipc-system-simple

Perl module to make running system commands and capturing errors as simple as possible.
http://search.cpan.org/perldoc?IPC::System::Simple
Other
19 stars 20 forks source link

Use ternary expressions with wantarray #26

Closed happy-barney closed 4 years ago

happy-barney commented 6 years ago

so finalize code doesn't need to be duplicated.

(pull request challenge 2018)

happy-barney commented 4 years ago

Primary motivation behind this PR is to get rid of duplication of _process_child_error calls in form:

if (condition) {
   ... do something
   _process_child_error();
   return ...
} else {
   ... do something else
   _process_child_error();
   return ...
}

Such construct is prone to introduce bugs when something is introduced only in one branch, so although it doesn't introduce new functionality, it just makes it little bit less likely to introduce a buggy feature.

jkeenan commented 4 years ago

Primary motivation behind this PR is to get rid of duplication of _process_child_error calls in form:

if (condition) {
   ... do something
   _process_child_error();
   return ...
} else {
   ... do something else
   _process_child_error();
   return ...
}

Such construct is prone to introduce bugs when something is introduced only in one branch, so although it doesn't introduce new functionality, it just makes it little bit less likely to introduce a buggy feature.

Sorry, I'm not persuaded that the benefit outweighs the risk.

Thank you very much. Jim Keenan