From 551e6a45c4853d4239060bae978cf7f97a75c718 Mon Sep 17 00:00:00 2001
From: Cinder <cinder@sdf.org>
Date: Mon, 12 Jan 2015 10:44:14 -0700
Subject: [PATCH] STORM-1949

---
 doc/contributions.txt              |  1 +
 indra/newview/llexternaleditor.cpp | 18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 042efca6b5..de59cb137f 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -321,6 +321,7 @@ Cinder Roxley
     STORM-1958
     STORM-1952
     STORM-1951
+    STORM-1949
     STORM-2035
     STORM-2036
     STORM-2037
diff --git a/indra/newview/llexternaleditor.cpp b/indra/newview/llexternaleditor.cpp
index 271e4d7d9d..d1116918a6 100755
--- a/indra/newview/llexternaleditor.cpp
+++ b/indra/newview/llexternaleditor.cpp
@@ -43,8 +43,22 @@ LLExternalEditor::EErrorCode LLExternalEditor::setCommand(const std::string& env
 	std::string cmd = findCommand(env_var, override);
 	if (cmd.empty())
 	{
-		LL_WARNS() << "Editor command is empty or not set" << LL_ENDL;
-		return EC_NOT_SPECIFIED;
+		LL_INFOS() << "Editor command is empty or not set. Falling back on generic open handler." << LL_ENDL;
+#if LL_WINDOWS
+		std::string comspec(getenv("COMSPEC"));
+		comspec.append(" /C START \"%s\"");
+		cmd = findCommand(LLStringUtil::null, comspec);
+#elif LL_DARWIN
+		cmd = findCommand(LLStringUtil::null, "/usr/bin/open \"%s\"");
+#elif LL_LINUX
+		// xdg-open might not actually be installed on all distros, but it's our best bet.
+		cmd = findCommand(LLStringUtil::null, "/usr/bin/xdg-open \"%s\"");
+#endif
+		if (cmd.empty())
+		{
+			LL_WARNS() << "Failed to find generic open handler: " << cmd << LL_ENDL;
+			return EC_NOT_SPECIFIED;
+		}
 	}
 
 	string_vec_t tokens;
-- 
GitLab