Skip to content

Commit

Permalink
Use browser in BROWSER env if present for doc command
Browse files Browse the repository at this point in the history
If the BROWSER enviroment variable is found, it is used as a list of
commands to be tested before the hardcoded ones to launch a browser.

Issue #1287
  • Loading branch information
naufraghi committed Nov 6, 2017
1 parent ab75525 commit e735538
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rustup-utils/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,15 @@ pub fn open_browser(path: &Path) -> io::Result<bool> {
#[cfg(not(windows))]
fn inner(path: &Path) -> io::Result<bool> {
use std::process::Stdio;
use std::env;

let env_browser = env::var_os("BROWSER").map(|b| env::split_paths(&b).collect::<Vec<_>>());
let env_commands = env_browser.as_ref()
.map(|cmds| cmds.iter().by_ref().filter_map(|b| b.to_str()).collect())
.unwrap_or(vec![]);

let commands = ["xdg-open", "open", "firefox", "chromium", "sensible-browser"];
if let Some(cmd) = find_cmd(&commands) {
if let Some(cmd) = find_cmd(&env_commands).or(find_cmd(&commands)) {
Command::new(cmd)
.arg(path)
.stdin(Stdio::null())
Expand Down

0 comments on commit e735538

Please sign in to comment.