Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use POSIX-compliant . instead of source in .profile #2616

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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