summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-05-10 22:28:59 +0000
committerNorbert Preining <preining@logic.at>2009-05-10 22:28:59 +0000
commit6de27e9b713edc74f7b60e13d2abfc7430dc7939 (patch)
tree29939408107f81eff397f71527136a92185a4d87
parentfd7bb5c1f100d4dc13efa56620e7d534d2f4fd2e (diff)
add run_cmd to TLUtils
git-svn-id: svn://tug.org/texlive/branches/branch2009-dev@13035 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm23
1 files changed, 22 insertions, 1 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index c7b98f0db48..cd5fc335235 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -32,6 +32,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure
TeXLive::TLUtils::tl_tmpdir();
TeXLive::TLUtils::xchdir($dir);
TeXLive::TLUtils::xsystem(@args);
+ TeXLive::TLUtils::run_cmd($cmd);
=head2 File Utilities
@@ -114,10 +115,11 @@ BEGIN {
&give_ctan_mirror
&tlmd5
&xsystem
+ &run_cmd
);
@EXPORT = qw(setup_programs download_file process_logging_options
tlwarn info log debug ddebug dddebug debug_hash
- win32 xchdir xsystem);
+ win32 xchdir xsystem run_cmd);
}
use Cwd;
@@ -399,6 +401,25 @@ sub xsystem
}
}
+=item C<run_cmd($cmd)>
+
+runs a command and captures its output. Then returns a list with the
+output as first element and the return value (exit code) as second.
+
+=cut
+
+sub run_cmd {
+ my $cmd = shift;
+ my $output = `$cmd`;
+ $retval = $?
+ if ($retval != 0) {
+ $retval /= 256 if $retval > 0;
+ }
+ return ($output, $retval);
+}
+
+
+
=back