Skip to content
Open
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
9 changes: 8 additions & 1 deletion src/shell_install/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ pub fn install(si: &mut ShellInstall) -> Result<(), ShellInstallError> {
return Ok(());
}
let escaped_path = link_path.to_string_lossy().replace(' ', "\\ ");
let source_line = format!("source {}", &escaped_path);
let source_line = {
if env::consts::OS == "windows" {
// Bash on Windows doesn't like C:\Users\... but will accept "C:\Users\..."
format!("source \"{}\"", &escaped_path)
} else {
format!("source {}", &escaped_path)
}
};
for sourcing_path in &sourcing_paths {
let sourcing_path_str = sourcing_path.to_string_lossy();
if util::file_contains_line(sourcing_path, &source_line)? {
Expand Down
7 changes: 6 additions & 1 deletion src/verb/execution_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,10 @@ mod execution_builder_test {
}

fn path_to_string<P: AsRef<Path>>(path: P) -> String {
path.as_ref().to_string_lossy().to_string()
let is_bash_on_windows = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget something here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, deliberately so! I have hardcoded it locally to allow me to test broot in Windows bash, and when I've done some testing I'll implement the best method.

This is more of a CTA for any similar bugs that I can fix in one shot.

if is_bash_on_windows {
format!("\"{}\"", path.as_ref().to_string_lossy().to_string())
} else {
path.as_ref().to_string_lossy().to_string()
}
}