Commit 8a9d843d authored by Roumen Petrov's avatar Roumen Petrov

exclude PATH component if content cannot be listed

Even system PATH could contain directory component without read(scan) permission. Exclude such items in search for "command aliases".

Fixes #21.
parent 2937fc5f
......@@ -84,8 +84,15 @@ private void printExternalAliases(PrintStream out) {
for (String entry : PathSettings.buildPATH().split(File.pathSeparator)) {
File dir = new File(entry);
for (File cmd : dir.listFiles(file -> pattern.matcher(file.getName()).matches())) {
File[] cmdlist = null;
try {
cmdlist = dir.listFiles(file -> pattern.matcher(file.getName()).matches());
} catch (Exception ignore) {
}
if (cmdlist == null) continue;
for (File cmd : cmdlist) {
ProcessBuilder pb = new ProcessBuilder(cmd.getPath(), "aliases");
try {
java.lang.Process p = pb.start();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment