[lintian] 01/04: L::Command: Add support for shell-like redirects for out/err
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 06d8c940628a6299755a8cfd3aeef5a470a0f782
Author: Niels Thykier <niels@thykier.net>
Date: Sun Sep 14 12:49:00 2014 +0200
L::Command: Add support for shell-like redirects for out/err
Signed-off-by: Niels Thykier <niels@thykier.net>
---
debian/changelog | 2 ++
lib/Lintian/Command.pm | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 4a2cd25..57a327e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,8 @@ lintian (2.5.28) UNRELEASED; urgency=medium
* lib/Lintian/Command.pm:
+ [NT] Add support for running a sub in the child before
it calls exec.
+ + [NT] Add support for shell-like (e.g. &2) redirects of
+ stdout and stderr.
-- Niels Thykier <niels@thykier.net> Sun, 14 Sep 2014 08:55:45 +0200
diff --git a/lib/Lintian/Command.pm b/lib/Lintian/Command.pm
index 2b7bf09..7bf38f7 100644
--- a/lib/Lintian/Command.pm
+++ b/lib/Lintian/Command.pm
@@ -102,6 +102,8 @@ STDOUT of the last forked child. Will be set to a newly created
scalar reference by default which can be used to retrieve the output
after the call.
+Can be '&N' (e.g. &2) to redirect it to (numeric) file descriptor.
+
=item out_append
STDOUT of all forked children, cannot be used with out and should only be
@@ -118,6 +120,8 @@ process to end properly.
STDERR of all forked children. Defaults to STDERR of the parent.
+Can be '&N' (e.g. &1) to redirect it to (numeric) file descriptor.
+
=item err_append
STDERR of all forked children, cannot be used with err and should only be
@@ -203,7 +207,11 @@ sub spawn {
} else {
if (!exists $opts->{out} && defined $opts->{out_append}){
@out = ('>>', $opts->{out_append});
+ } elsif ($opts->{out} && substr($opts->{out}, 0, 1) eq '&') {
+ # >&2 redirects must be a single string
+ @err = ('>' . $opts->{out});
} else {
+ # Generic redirect to files, scalar refs or open fds
$opts->{out} ||= \$out;
@out = ('>', $opts->{out});
}
@@ -214,7 +222,11 @@ sub spawn {
} else {
if (!exists $opts->{err} && defined $opts->{err_append}){
@err = ('2>>', $opts->{err_append});
+ } elsif ($opts->{err} && substr($opts->{err}, 0, 1) eq '&') {
+ # 2>&1 redirects must be a single string
+ @err = ('2>' . $opts->{err});
} else {
+ # Generic redirect to files, scalar refs or open fds
$opts->{err} ||= \*STDERR;
@err = ('2>', $opts->{err});
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: