Skip to content

Commit

Permalink
Use POSIX-compliant . instead of source in .profile
Browse files Browse the repository at this point in the history
The invocation to `source` introduced in 850adef is not POSIX-compliant,
and not available in some shells. Use `.` instead, which will work in
all shells. Concretely, this was failing in Docker builds, where
`/bin/sh` is not Bash.
  • Loading branch information
Xyene committed Dec 20, 2020
1 parent 50fbbeb commit cf6b1cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 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
4 changes: 2 additions & 2 deletions tests/cli-paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 cf6b1cb

Please sign in to comment.