Skip to content

Commit 085a23b

Browse files
authored
Merge pull request #2616 from Xyene/posix-source
Use POSIX-compliant `.` instead of `source` in .profile
2 parents 50fbbeb + 59eaf8f commit 085a23b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cli/self_update/shell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub trait UnixShell {
9898
}
9999

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

tests/cli-paths.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod unix {
2020
// Let's write a fake .rc which looks vaguely like a real script.
2121
const FAKE_RC: &str = r#"
2222
# Sources fruity punch.
23-
source ~/fruit/punch
23+
. ~/fruit/punch
2424
2525
# Adds apples to PATH.
2626
export PATH="$HOME/apple/bin"
@@ -29,7 +29,7 @@ export PATH="$HOME/apple/bin"
2929
const POSIX_SH: &str = "env";
3030

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

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

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

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

0 commit comments

Comments
 (0)