summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2017-08-03 19:32:44 +0000
committerNiels Thykier <niels@thykier.net>2017-08-03 19:32:44 +0000
commitd3870e78e9a38bbe9bd8759dbaa3c912140a9cf1 (patch)
tree1558095fe4c8431511f1ff1a28dcc49f196a4faf
parent742db48fd9c5995845b57a27e068e3f50bbd5262 (diff)
downloaddebhelper-d3870e78e9a38bbe9bd8759dbaa3c912140a9cf1.tar.gz
Dh_Lib: Introduce qx_cmd
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--Debian/Debhelper/Dh_Lib.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 4a3d69bd..07866907 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -63,7 +63,7 @@ our (@EXPORT, %dh);
XARGS_INSERT_PARAMS_HERE &glob_expand_error_handler_reject
&glob_expand_error_handler_warn_and_discard &glob_expand
&glob_expand_error_handler_silently_ignore DH_BUILTIN_VERSION
- &print_and_complex_doit &default_sourcedir
+ &print_and_complex_doit &default_sourcedir &qx_cmd
);
# The Makefile changes this if debhelper is installed in a PREFIX.
@@ -342,6 +342,19 @@ sub _format_cmdline {
return $cmd_line;
}
+sub qx_cmd {
+ my (@cmd) = @_;
+ my $output;
+ open(my $fd, '-|', @cmd) or error('fork+exec (' . escape_shell(@cmd) . "): $!");
+ local $/ = undef;
+ $output = <$fd>;
+ if (not close($fd)) {
+ error("close pipe failed: $!") if $!;
+ error_exitcode(escape_shell(@cmd));
+ }
+ return $output;
+}
+
# Run a command and display the command to stdout if verbose mode is on.
# Use doit() if you can, instead of this function, because this function
# forks a shell. However, this function can handle more complicated stuff