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

Update .cshrc and .tcshrc if present #1108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,8 @@ fn get_shell_script_juliaup_content(bin_path: &Path, path: &Path) -> Result<Vec<
result.extend_from_slice(HEADER);
if path.file_name().unwrap() == ".zshrc" {
append_zsh_content(&mut result, bin_path_str);
} else if path.file_name().unwrap() == ".cshrc" || path.file_name().unwrap() == ".tcshrc" {
append_csh_content(&mut result, bin_path_str);
} else {
append_sh_content(&mut result, bin_path_str);
}
Expand All @@ -1072,6 +1074,18 @@ fn append_zsh_content(buf: &mut Vec<u8>, path_str: &str) {
buf.extend_from_slice(content.as_bytes());
}

fn append_csh_content(buf: &mut Vec<u8>, path_str: &str) {
// csh specific syntax for path extension
let content = formatdoc!(
"
set path = ($path {})
",
path_str
);

buf.extend_from_slice(content.as_bytes());
}

fn append_sh_content(buf: &mut Vec<u8>, path_str: &str) {
// If the variable is already contained in $PATH, do nothing
// Otherwise prepend it to path
Expand Down Expand Up @@ -1209,6 +1223,8 @@ pub fn find_shell_scripts_to_be_modified(add_case: bool) -> Result<Vec<PathBuf>>
home_dir.join(".bash_profile"),
home_dir.join(".bash_login"),
home_dir.join(".zshrc"),
home_dir.join(".cshrc"),
home_dir.join(".tcshrc"),
];

let result = paths_to_test
Expand Down
Loading