Skip to content

Commit

Permalink
Strip upper-case version of EXE_SUFFIX (#57)
Browse files Browse the repository at this point in the history
On windows, file paths are case insensitive, so `binary.EXE` should be treated just like `binary.exe`. Interestingly, command prompt will return a lowercase extension as the current exe name, whilst PowerShell does not.

Fixes #54
  • Loading branch information
JohnnyMorganz committed May 2, 2024
1 parent 412d5b5 commit 3bf0f49
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ fn current_exe_name() -> anyhow::Result<String> {
.and_then(|name| name.to_str())
.ok_or_else(|| format_err!("OS gave a funny result when asking for executable name"))?;

exe_name = exe_name.strip_suffix(EXE_SUFFIX).unwrap_or(exe_name);
exe_name = exe_name
.strip_suffix(EXE_SUFFIX)
// See https://github.com/LPGhatguy/aftman/issues/54: handle windows file extension case-insensitivity
.or_else(|| exe_name.strip_suffix(&EXE_SUFFIX.to_uppercase()))
.unwrap_or(exe_name);

Ok(exe_name.to_owned())
}
Expand Down

0 comments on commit 3bf0f49

Please sign in to comment.