From 9889d7ced4779b6afc09915bc6f47206957b63f0 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 10 Oct 2023 20:24:16 +0800 Subject: [PATCH 1/3] Add suggestions to mention sourcing `env.fish` --- src/cli/self_update.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index e3823980af..854e32e2c8 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -225,13 +225,12 @@ This would reload your `PATH` environment variable to include Cargo's bin directory ({cargo_home}/bin). To configure your current shell, you need to source -the `env` file ({cargo_home}/env). +the corresponding `env` file under {cargo_home}. -This is usually done by running: - source "{cargo_home}/env" - -The `source` command above might need to be replaced with `.` -on shells like `ash`, `dash` and `pdksh`. +This is usually done by running one of the following: + source "{cargo_home}/env" # For bash/zsh + . "{cargo_home}/env" # For ash/dash/pdksh (note the leading DOT) + source "{cargo_home}/env.fish" # For fish "# }; } @@ -258,13 +257,12 @@ To get started you need Cargo's bin directory ({cargo_home}/bin) in your `PATH` environment variable. This has not been done automatically. To configure your current shell, you need to source -the `env` file ({cargo_home}/env). - -This is usually done by running: - source "{cargo_home}/env" +the corresponding `env` file under {cargo_home}. -The `source` command above might need to be replaced with `.` -on shells like `ash`, `dash` and `pdksh`. +This is usually done by running one of the following: + source "{cargo_home}/env" # For bash/zsh + . "{cargo_home}/env" # For ash/dash/pdksh (note the leading DOT) + source "{cargo_home}/env.fish" # For fish "# }; } From 75f06bff326de3f5972366e2d24ed52b130c0b54 Mon Sep 17 00:00:00 2001 From: rami3l Date: Wed, 11 Oct 2023 14:03:59 +0800 Subject: [PATCH 2/3] Extract `post_install_msg_unix_source_env!()` --- src/cli/self_update.rs | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 854e32e2c8..b839665685 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -216,15 +216,9 @@ but will not be added automatically." } #[cfg(not(windows))] -macro_rules! post_install_msg_unix { +macro_rules! post_install_msg_unix_source_env { () => { - r#"# Rust is installed now. Great! - -To get started you may need to restart your current shell. -This would reload your `PATH` environment variable to include -Cargo's bin directory ({cargo_home}/bin). - -To configure your current shell, you need to source + r#"To configure your current shell, you need to source the corresponding `env` file under {cargo_home}. This is usually done by running one of the following: @@ -235,6 +229,22 @@ This is usually done by running one of the following: }; } +#[cfg(not(windows))] +macro_rules! post_install_msg_unix { + () => { + concat!( + r"# Rust is installed now. Great! + +To get started you may need to restart your current shell. +This would reload your `PATH` environment variable to include +Cargo's bin directory ({cargo_home}/bin). + +", + post_install_msg_unix_source_env!(), + ) + }; +} + #[cfg(windows)] macro_rules! post_install_msg_win { () => { @@ -251,19 +261,15 @@ Cargo's bin directory ({cargo_home}\\bin). #[cfg(not(windows))] macro_rules! post_install_msg_unix_no_modify_path { () => { - r#"# Rust is installed now. Great! + concat!( + r"# Rust is installed now. Great! To get started you need Cargo's bin directory ({cargo_home}/bin) in your `PATH` environment variable. This has not been done automatically. -To configure your current shell, you need to source -the corresponding `env` file under {cargo_home}. - -This is usually done by running one of the following: - source "{cargo_home}/env" # For bash/zsh - . "{cargo_home}/env" # For ash/dash/pdksh (note the leading DOT) - source "{cargo_home}/env.fish" # For fish -"# +", + post_install_msg_unix_source_env!(), + ) }; } From 10de7bf14bf1691c1d090ab43f167489c9f39cb6 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 10 Oct 2023 20:27:57 +0800 Subject: [PATCH 3/3] Apply `clippy` suggestions --- src/cli/self_update/shell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/self_update/shell.rs b/src/cli/self_update/shell.rs index 4983a5dd4a..fdd220e235 100644 --- a/src/cli/self_update/shell.rs +++ b/src/cli/self_update/shell.rs @@ -212,7 +212,7 @@ impl UnixShell for Fish { fn does_exist(&self) -> bool { // fish has to either be the shell or be callable for fish setup. matches!(process().var("SHELL"), Ok(sh) if sh.contains("fish")) - || matches!(utils::find_cmd(&["fish"]), Some(_)) + || utils::find_cmd(&["fish"]).is_some() } // > "$XDG_CONFIG_HOME/fish/conf.d" (or "~/.config/fish/conf.d" if that variable is unset) for the user