diff --git a/modules/juce_core/native/juce_linux_Files.cpp b/modules/juce_core/native/juce_linux_Files.cpp index 5e34d6a717..505b9b285f 100644 --- a/modules/juce_core/native/juce_linux_Files.cpp +++ b/modules/juce_core/native/juce_linux_Files.cpp @@ -189,40 +189,36 @@ static bool isFileExecutable (const String& filename) bool Process::openDocument (const String& fileName, const String& parameters) { - String cmdString (fileName.replace (" ", "\\ ",false)); + auto cmdString = fileName.replace (" ", "\\ ", false); cmdString << " " << parameters; - if (/*URL::isProbablyAWebsiteURL (fileName) - ||*/ cmdString.startsWithIgnoreCase ("file:") - /*|| URL::isProbablyAnEmailAddress (fileName)*/ + if (cmdString.startsWithIgnoreCase ("file:") || File::createFileWithoutCheckingPath (fileName).isDirectory() || ! isFileExecutable (fileName)) { - // create a command that tries to launch a bunch of likely browsers - static const char* const browserNames[] = { "xdg-open", "/etc/alternatives/x-www-browser", "firefox", "mozilla", - "google-chrome", "chromium-browser", "opera", "konqueror" }; StringArray cmdLines; - for (int i = 0; i < numElementsInArray (browserNames); ++i) - cmdLines.add (String (browserNames[i]) + " " + cmdString.trim().quoted()); + for (auto browserName : { "xdg-open", "/etc/alternatives/x-www-browser", "firefox", "mozilla", + "google-chrome", "chromium-browser", "opera", "konqueror" }) + { + cmdLines.add (String (browserName) + " " + cmdString.trim()); + } cmdString = cmdLines.joinIntoString (" || "); } const char* const argv[4] = { "/bin/sh", "-c", cmdString.toUTF8(), 0 }; - const int cpid = fork(); - - if (cpid == 0) + if (fork() == 0) { setsid(); - - // Child process execve (argv[0], (char**) argv, environ); exit (0); + + return true; } - return cpid >= 0; + return false; } void File::revealToUser() const