Skip to content

Commit

Permalink
Properly quote $(location ) expansion for the shell
Browse files Browse the repository at this point in the history
...by using the ShellEscaper rather than the ad-hoc "escaping"
in LocationExpander.

Fixes bazelbuild#5190. At least to the extend that a context-independent
quoting can work.

Change-Id: I858662861a2504139c19d773690aef2befc23948
PiperOrigin-RevId: 196832574
  • Loading branch information
aehlig authored and Copybara-Service committed May 16, 2018
1 parent 1045300 commit bf43c3a
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.OutputFile;
import com.google.devtools.build.lib.packages.RuleErrorConsumer;
import com.google.devtools.build.lib.util.ShellEscaper;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -315,15 +316,7 @@ private Set<String> getPaths(Collection<Artifact> artifacts, boolean takeExecPat
}

private String joinPaths(Collection<String> paths) {
return paths.stream().map(LocationFunction::quotePath).collect(joining(" "));
}

private static String quotePath(String path) {
// TODO(ulfjack): Use existing ShellEscaper instead.
if (path.contains(" ")) {
path = "'" + path + "'";
}
return path;
return paths.stream().map(ShellEscaper::escapeString).collect(joining(" "));
}

private String functionName() {
Expand Down

0 comments on commit bf43c3a

Please sign in to comment.