Skip to content

Commit

Permalink
detect and handle cygwin in install::sanitize_sh
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Dec 8, 2024
1 parent ae3703c commit fc1d2e5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bootstrap/src/core/build_steps/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ const SHELL: &str = "sh";
/// characters and on `C:\` paths, so normalize both of them away.
fn sanitize_sh(path: &Path) -> String {
let path = path.to_str().unwrap().replace('\\', "/");
return change_drive(unc_to_lfs(&path)).unwrap_or(path);
return if is_cygwin() { path } else { change_drive(unc_to_lfs(&path)).unwrap_or(path) };

fn is_cygwin() -> bool {
// ref. https://cygwin.com/pipermail/cygwin/2022-February/250802.html
env::var("OSTYPE").map_or(false, |v| v.to_lowercase().contains("cygwin"))
}

fn unc_to_lfs(s: &str) -> &str {
s.strip_prefix("//?/").unwrap_or(s)
Expand Down

0 comments on commit fc1d2e5

Please sign in to comment.