Skip to content

Commit

Permalink
workspace: Canonicalize file paths to use forward slash
Browse files Browse the repository at this point in the history
This avoids issues when using paths in replacement strings in ${replace}
macro.

Signed-off-by: BJ Hargrave <bj@bjhargrave.com>
  • Loading branch information
bjhargrave committed Apr 17, 2018
1 parent 5437a1d commit c7f942b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion biz.aQute.bndlib/src/aQute/bnd/build/Workspace.java
Expand Up @@ -378,7 +378,8 @@ public void propertiesChanged() {
}

public String _workspace(@SuppressWarnings("unused") String args[]) {
return getBase().getAbsolutePath();
return getBase().getAbsolutePath()
.replace('\\', '/');
}

public void addCommand(String menu, Action action) {
Expand Down
6 changes: 4 additions & 2 deletions biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java
Expand Up @@ -719,7 +719,8 @@ public String _dir(String args[]) {
.exists()) {
sb.append(del);
sb.append(f.getParentFile()
.getAbsolutePath());
.getAbsolutePath()
.replace('\\', '/'));
del = ",";
}
}
Expand Down Expand Up @@ -1306,7 +1307,8 @@ public String _osfile(String args[]) {
verifyCommand(args, _fileHelp, null, 3, 3);
File base = new File(args[1]);
File f = Processor.getFile(base, args[2]);
return f.getAbsolutePath();
return f.getAbsolutePath()
.replace('\\', '/');
}

public String _path(String args[]) {
Expand Down
8 changes: 5 additions & 3 deletions biz.aQute.bndlib/src/aQute/bnd/osgi/Processor.java
Expand Up @@ -899,7 +899,8 @@ public String _basedir(@SuppressWarnings("unused") String args[]) {
if (base == null)
throw new IllegalArgumentException("No base dir set");

return base.getAbsolutePath();
return base.getAbsolutePath()
.replace('\\', '/');
}

public String _propertiesname(String[] args) {
Expand All @@ -925,7 +926,8 @@ public String _propertiesdir(String[] args) {
return "";

return pf.getParentFile()
.getAbsolutePath();
.getAbsolutePath()
.replace('\\', '/');
}

static String _uri = "${uri;<uri>[;<baseuri>]}, Resolve the uri against the baseuri. baseuri defaults to the processor base.";
Expand Down Expand Up @@ -2683,7 +2685,7 @@ public String _thisfile(String[] args) {
}

return propertiesFile.getAbsolutePath()
.replaceAll("\\\\", "/");
.replace('\\', '/');
}

/**
Expand Down

0 comments on commit c7f942b

Please sign in to comment.