Skip to content

Commit 793aac3

Browse files
authored
Merge pull request #1289 from naufraghi/issue/1287/rustup-doc-browser
Use command in BROWSER env if present for `doc` command
2 parents 525adef + cbb6aeb commit 793aac3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rustup-utils/src/raw.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ pub fn open_browser(path: &Path) -> io::Result<bool> {
364364
#[cfg(not(windows))]
365365
fn inner(path: &Path) -> io::Result<bool> {
366366
use std::process::Stdio;
367+
use std::env;
368+
369+
let env_browser = env::var_os("BROWSER").map(|b| env::split_paths(&b).collect::<Vec<_>>());
370+
let env_commands = env_browser.as_ref()
371+
.map(|cmds| cmds.iter().by_ref().filter_map(|b| b.to_str()).collect())
372+
.unwrap_or(vec![]);
367373

368374
let commands = [
369375
"xdg-open",
@@ -372,7 +378,7 @@ pub fn open_browser(path: &Path) -> io::Result<bool> {
372378
"chromium",
373379
"sensible-browser",
374380
];
375-
if let Some(cmd) = find_cmd(&commands) {
381+
if let Some(cmd) = find_cmd(&env_commands).or(find_cmd(&commands)) {
376382
Command::new(cmd)
377383
.arg(path)
378384
.stdin(Stdio::null())

0 commit comments

Comments
 (0)