|
27 | 27 | import java.nio.charset.StandardCharsets; |
28 | 28 | import java.nio.file.FileSystems; |
29 | 29 | import java.nio.file.Files; |
| 30 | +import java.nio.file.Path; |
30 | 31 | import java.nio.file.Paths; |
31 | 32 | import java.util.ArrayList; |
32 | 33 | import java.util.HashMap; |
@@ -294,14 +295,17 @@ private String tokenViaExecCredential(Map<String, Object> execMap) { |
294 | 295 |
|
295 | 296 | private JsonElement runExec(String command, List<String> args, List<Map<String, String>> env) { |
296 | 297 | List<String> argv = new ArrayList<>(); |
297 | | - if (command.startsWith("./")) { |
298 | | - // TODO spec is unclear on what should be treated as a “relative command path” |
299 | | - File resolvedCommand = new File(file.getParentFile(), command); |
300 | | - if (!resolvedCommand.isFile()) { |
| 298 | + if (command.contains("/") || command.contains("\\")) { |
| 299 | + // Spec is unclear on what should be treated as a “relative command path”. |
| 300 | + // This clause should cover anything not resolved from $PATH / %Path%. |
| 301 | + Path resolvedCommand = file.toPath().getParent().resolve(command).normalize(); |
| 302 | + if (!Files.exists(resolvedCommand)) { |
301 | 303 | log.error("No such file: {}", resolvedCommand); |
302 | 304 | return null; |
303 | 305 | } |
304 | | - argv.add(resolvedCommand.getAbsolutePath()); |
| 306 | + // Not checking isRegularFile or isExecutable here; leave that to ProcessBuilder.start. |
| 307 | + log.debug("Resolved {} to {}", command, resolvedCommand); |
| 308 | + argv.add(resolvedCommand.toString()); |
305 | 309 | } else { |
306 | 310 | argv.add(command); |
307 | 311 | } |
|
0 commit comments