8285987: executing shell scripts without #! fails on Alpine linux
Reviewed-by: mdoerr, goetz
This commit is contained in:
parent
fd41e65fa8
commit
9d2f591e6a
@ -486,15 +486,15 @@ public class Basic {
|
||||
equal(run(pb).exitValue(),
|
||||
False.exitValue());
|
||||
// Traditional shell scripts without #!
|
||||
setFileContents(prog, "exec /bin/true\n");
|
||||
prog.setExecutable(true);
|
||||
equal(run(pb).exitValue(),
|
||||
True.exitValue());
|
||||
prog.delete();
|
||||
setFileContents(prog, "exec /bin/false\n");
|
||||
prog.setExecutable(true);
|
||||
equal(run(pb).exitValue(),
|
||||
False.exitValue());
|
||||
if (!(Platform.isLinux() && Platform.isMusl())) {
|
||||
setFileContents(prog, "exec /bin/true\n");
|
||||
prog.setExecutable(true);
|
||||
equal(run(pb).exitValue(), True.exitValue());
|
||||
prog.delete();
|
||||
setFileContents(prog, "exec /bin/false\n");
|
||||
prog.setExecutable(true);
|
||||
equal(run(pb).exitValue(), False.exitValue());
|
||||
}
|
||||
prog.delete();
|
||||
}
|
||||
|
||||
@ -511,14 +511,16 @@ public class Basic {
|
||||
pb.command(cmd);
|
||||
|
||||
// Test traditional shell scripts without #!
|
||||
setFileContents(dir1Prog, "/bin/echo \"$@\"\n");
|
||||
pb.command(new String[] {"prog", "hello", "world"});
|
||||
checkPermissionDenied(pb);
|
||||
dir1Prog.setExecutable(true);
|
||||
equal(run(pb).out(), "hello world\n");
|
||||
equal(run(pb).exitValue(), True.exitValue());
|
||||
dir1Prog.delete();
|
||||
pb.command(cmd);
|
||||
if (!(Platform.isLinux() && Platform.isMusl())) {
|
||||
setFileContents(dir1Prog, "/bin/echo \"$@\"\n");
|
||||
pb.command(new String[] {"prog", "hello", "world"});
|
||||
checkPermissionDenied(pb);
|
||||
dir1Prog.setExecutable(true);
|
||||
equal(run(pb).out(), "hello world\n");
|
||||
equal(run(pb).exitValue(), True.exitValue());
|
||||
dir1Prog.delete();
|
||||
pb.command(cmd);
|
||||
}
|
||||
|
||||
// If prog found on both parent and child's PATH,
|
||||
// parent's is used.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
* @test
|
||||
* @summary Testing external editor.
|
||||
* @bug 8143955 8080843 8163816 8143006 8169828 8171130 8162989 8210808
|
||||
* @comment musl/Alpine has problems executing some shell scripts, see 8285987
|
||||
* @requires !vm.musl
|
||||
* @modules jdk.jshell/jdk.internal.jshell.tool
|
||||
* @build ReplToolTesting CustomEditor EditorTestBase
|
||||
* @run testng ExternalEditorTest
|
||||
|
@ -189,6 +189,19 @@ public class Platform {
|
||||
return vmVersion;
|
||||
}
|
||||
|
||||
public static boolean isMusl() {
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder("ldd", "--version");
|
||||
pb.redirectErrorStream(true);
|
||||
Process p = pb.start();
|
||||
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
String l = b.readLine();
|
||||
if (l != null && l.contains("musl")) { return true; }
|
||||
} catch(Exception e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAArch64() {
|
||||
return isArch("aarch64");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user