[tbb-commits] [Git][tpo/applications/rbm][main] Bug 40068: Use Capture::Tiny instead of IO::CaptureOutput

richard (@richard) git at gitlab.torproject.org
Thu Jan 25 11:03:01 UTC 2024



richard pushed to branch main at The Tor Project / Applications / RBM


Commits:
9336d42f by Nicolas Vigier at 2024-01-25T11:42:58+01:00
Bug 40068: Use Capture::Tiny instead of IO::CaptureOutput

The IO::CaptureOutput perl module is deprecated, so we switch to
Capture::Tiny.

The Capture::Tiny module does not provide a capture_exec function
similar to the one from IO::CaptureOutput, so we implement one using the
same name, which avoids changing all the places where we were using it.

- - - - -


2 changed files:

- lib/RBM.pm
- lib/RBM/DefaultConfig.pm


Changes:

=====================================
lib/RBM.pm
=====================================
@@ -10,7 +10,7 @@ use YAML::XS qw(LoadFile);
 use Template;
 use File::Basename;
 use IO::Handle;
-use IO::CaptureOutput qw(capture_exec);
+use Capture::Tiny qw(capture);
 use File::Temp;
 use File::Copy;
 use File::Copy::Recursive qw(fcopy);
@@ -29,7 +29,7 @@ use feature "state";
 BEGIN {
     require Exporter;
     our @ISA = qw(Exporter);
-    our @EXPORT = qw(exit_error);
+    our @EXPORT = qw(exit_error capture_exec);
 }
 
 our $config;
@@ -308,6 +308,15 @@ sub exit_error {
     exit (exists $_[1] ? $_[1] : 1);
 }
 
+sub capture_exec {
+    my @cmd = @_;
+    my ($stdout, $stderr, $exit) = capture {
+        system(@cmd);
+    };
+    return ($stdout, $stderr, $exit == 0, $exit) if wantarray();
+    return $stdout;
+}
+
 sub set_git_gpg_wrapper {
     my ($project) = @_;
     my $w = project_config($project, 'gpg_wrapper');


=====================================
lib/RBM/DefaultConfig.pm
=====================================
@@ -10,9 +10,8 @@ BEGIN {
 }
 
 use File::Basename;
-use RBM;
+use RBM qw(capture_exec);
 use Cwd qw(getcwd);
-use IO::CaptureOutput qw(capture_exec);
 use File::Temp;
 use File::Path qw(make_path);
 



View it on GitLab: https://gitlab.torproject.org/tpo/applications/rbm/-/commit/9336d42fdd669afbcd6c5c6196ecbf0ed1857f55

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/rbm/-/commit/9336d42fdd669afbcd6c5c6196ecbf0ed1857f55
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240125/5bd041fe/attachment-0001.htm>


More information about the tbb-commits mailing list