Skip to content

Commit a968304

Browse files
committed
The absence of -- in a command is usually a bug
In this case, a query like β€œHEAD grep=-V say 42” was failing. Not that it is a sensible query, but it shouldn't fail like that. Another possible solution is to use β€˜-e’ (which expects a pattern in the next argument), but it is slightly less explicit as I'm used to seeing -- everywhere (and also assuming that there's a bug if I don't see it).
1 parent c59c37c commit a968304

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

β€ŽCoverable.p6

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ method process($msg, $config is copy, $grep is copy, $code is copy) {
131131
$result = self.run-snippet: $full-commit, $filename;
132132
%*ENV<MVM_COVERAGE_LOG>:delete;
133133

134-
# TODO shell injection in $grep
135-
my $g = run 'grep', '-P', $grep, $log, :out;
134+
my $g = run 'grep', '-P', '--', $grep, $log, :out;
136135
my $s = run 'sort', '--key=2,2', '--key=3n', '-u', :in($g.out), :out;
137136
my $colrm = run 'colrm', 1, 5, :in($s.out), :out;
138137
$result<coverage> = $colrm.out.slurp-rest.chomp;

β€ŽGreppable.p6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ method process($msg) {
6262
my $result = self.get-output(|@git, β€˜grep’,
6363
β€˜--color=always’, β€˜-z’, β€˜-i’, β€˜-I’,
6464
β€˜--perl-regexp’, β€˜--line-number’,
65-
β€˜-e’, $msg);
65+
β€˜--’, $msg);
6666

6767
return β€˜Sorry, can't do that’ if $result<exit-code> β‰  0 & 1 or $result<signal> β‰  0;
6868
return β€˜Found nothing!’ unless $result<output>;

0 commit comments

Comments
Β (0)