path-convert: non-canonicalized arguments are now passed through correctly

This commit is contained in:
Valerie Wolfe 2024-07-16 09:54:58 -04:00
parent 2d88ac6f45
commit b204c440e2
3 changed files with 9 additions and 4 deletions

View file

@ -11,7 +11,11 @@
.Sh DESCRIPTION
The
.Nm
utility converts UNIX paths to DOS, for command substituting paths when invoking Windows executables from the terminal in WSL. Its options are as follows:
utility converts UNIX paths to DOS, for command substituting paths when invoking Windows executables from the terminal in WSL.
.Pp
Arguments that fail to canonicalize will be passed through as-is.
.Pp
Its options are as follows:
.Bl -tag -width Ds
.It Fl h , Fl -help
Displays a short help text.

View file

@ -1,6 +1,6 @@
[package]
name = "path-convert"
version = "0.0.6"
version = "0.0.7"
edition = "2021"
[dependencies]

View file

@ -42,11 +42,12 @@ pub fn main() {
// canonicalize; windows doesn't recognize symlinks
let path = Path::new(&target).canonicalize();
let mut output =
let mut output: String =
if let Ok(canonical) = path {
canonical.to_string_lossy().to_string()
} else {
target
println!("{quotes}{target}{quotes}");
continue;
};
// handle no-space flag