private static bool TryGetVersion(string directory, string command, out string version) { version = null; if (string.IsNullOrEmpty(command)) { return(false); } if (!Directory.Exists(directory)) { return(false); } var output = UTinyShell.RunInShell(command, new ShellProcessArgs() { ExtraPaths = directory.AsEnumerable(), ThrowOnError = false }); if (!output.Succeeded) { return(false); } version = output.CommandOutput; return(true); }
/// <summary> /// Runs the given command in the OS shell (cmd on Windows, bash on Mac/Linux). /// </summary> public static bool RunInShell(string command, ShellProcessArgs processArgs, bool outputOnErrorOnly = true) { var output = UTinyShell.RunInShell(command, processArgs); if (!output.Succeeded) { Debug.LogError($"{UTinyConstants.ApplicationName}: {output.FullOutput}"); } else if (!outputOnErrorOnly) { Debug.Log($"{UTinyConstants.ApplicationName}: {output.FullOutput}"); } return(output.Succeeded); }