diff options
author | Jean Delvare <jdelvare@suse.de> | 2014-02-12 21:03:03 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2014-02-12 21:03:03 +0100 |
commit | 172b633be53b4addf7e8784e7c28d16f369cea5f (patch) | |
tree | e88dce24ef3c0a0f185df756764bb366541d1e2d | |
parent | 826ec33980998186841451a52b721eaf0cc456c3 (diff) | |
download | quilt-172b633be53b4addf7e8784e7c28d16f369cea5f.tar.gz |
test/run: Use perl module Text::ParseWords
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%.
-rw-r--r-- | quilt.changes | 1 | ||||
-rwxr-xr-x | test/run | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/quilt.changes b/quilt.changes index fa35318..94a976c 100644 --- a/quilt.changes +++ b/quilt.changes @@ -2,6 +2,7 @@ Wed Feb 12 20:57:35 CET 2014 - jdelvare@suse.de - test/run: Delay command line splitting. +- test/run: Use perl module Text::ParseWords. ------------------------------------------------------------------- Mon Feb 10 13:07:14 CET 2014 - jdelvare@suse.de @@ -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]; |