[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [patch 2/8] test/run: Use perl module Text::ParseWords
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [patch 2/8] test/run: Use perl module Text::ParseWords |
Date: |
Sun, 02 Feb 2014 15:19:47 +0100 |
User-agent: |
quilt/0.61-1 |
Perl has a standard module which can split shell command lines for
us, so use it. Function shellwords can deal with quoted parameters
too so we no longer need to pass commands to /bin/sh just because
they contain quoted parameters. This lowers the ratio of commands
passed to /bin/sh from 34% to 31%.
---
test/run | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/test/run
+++ b/test/run
@@ -48,6 +48,7 @@ use strict;
use FileHandle;
use Getopt::Std;
use POSIX qw(isatty setuid getcwd);
+use Text::ParseWords;
use vars qw($opt_l $opt_q $opt_v %output);
no warnings qw(taint);
@@ -267,8 +268,8 @@ sub sg($) {
sub exec_test($$) {
my ($raw_prog, $in) = @_;
local (*IN, *IN_DUP, *IN2, *OUT_DUP, *OUT, *OUT2);
- my $prog = [ map { s/\\(.)/$1/g; $_ } split /(?<!\\)\s+/, $raw_prog ];
- my $needs_shell = ($raw_prog =~ /[][|<>;"'`\$\*\?]/);
+ my $prog = [ shellwords($raw_prog) ];
+ my $needs_shell = ($raw_prog =~ /[][|<>;`\$\*\?]/);
if ($prog->[0] eq "umask") {
umask oct $prog->[1];
- [Quilt-dev] [patch 0/8] test/run: Cleanups and optimizations, Jean Delvare, 2014/02/02
- [Quilt-dev] [patch 1/8] test/run: Delay command line splitting, Jean Delvare, 2014/02/02
- [Quilt-dev] [patch 2/8] test/run: Use perl module Text::ParseWords,
Jean Delvare <=
- [Quilt-dev] [patch 3/8] test/run: Drop support for su and sg, Jean Delvare, 2014/02/02
- [Quilt-dev] [patch 5/8] test/run: Reorder functions, Jean Delvare, 2014/02/02
- [Quilt-dev] [patch 6/8] test/run: Declare global variables as such, Jean Delvare, 2014/02/02
- [Quilt-dev] [patch 8/8] test/run: Minor performance optimizations, Jean Delvare, 2014/02/02
- [Quilt-dev] [patch 4/8] test/run: Massive reindentation, Jean Delvare, 2014/02/02
- [Quilt-dev] [patch 7/8] test/run: Fix the condition for using /bin/sh, Jean Delvare, 2014/02/02
- Re: [Quilt-dev] [patch 0/8] test/run: Cleanups and optimizations, Andreas Grünbacher, 2014/02/02