Skip to content

Commit

Permalink
Merge pull request #2616 from Xyene/posix-source
Browse files Browse the repository at this point in the history
Use POSIX-compliant `.` instead of `source` in .profile
  • Loading branch information
kinnison authored Dec 21, 2020
2 parents 50fbbeb + 59eaf8f commit 085a23b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cli/self_update/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub trait UnixShell {
}

fn source_string(&self) -> Result<String> {
Ok(format!(r#"source "{}/env""#, cargo_home_str()?))
Ok(format!(r#". "{}/env""#, cargo_home_str()?))
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/cli-paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod unix {
// Let's write a fake .rc which looks vaguely like a real script.
const FAKE_RC: &str = r#"
# Sources fruity punch.
source ~/fruit/punch
. ~/fruit/punch
# Adds apples to PATH.
export PATH="$HOME/apple/bin"
Expand All @@ -29,7 +29,7 @@ export PATH="$HOME/apple/bin"
const POSIX_SH: &str = "env";

fn source(dir: impl Display, sh: impl Display) -> String {
format!("source \"{dir}/{sh}\"\n", dir = dir, sh = sh)
format!(". \"{dir}/{sh}\"\n", dir = dir, sh = sh)
}

#[test]
Expand Down Expand Up @@ -273,7 +273,7 @@ export PATH="$HOME/apple/bin"
assert!(cmd.output().unwrap().status.success());

let new_profile = fs::read_to_string(&profile).unwrap();
let expected = format!("{}source \"$HOME/.cargo/env\"\n", FAKE_RC);
let expected = format!("{}. \"$HOME/.cargo/env\"\n", FAKE_RC);
assert_eq!(new_profile, expected);

let mut cmd = clitools::cmd(config, "rustup", &["self", "uninstall", "-y"]);
Expand Down

0 comments on commit 085a23b

Please sign in to comment.