I am running an .sh script from wsl bash.
Inside the script I want capture a file path, into a variable, in order to pass it to cmd.exe
like so:
my_win_path=<some_windows_unc_path_to_executable>
cmd.exe /c "$my_win_path"
However when I try to capture the file path, it's backslashes are getting formatted, resulting in an non-valid path.
Example:
~: wslpath -w .
C:\tmp
~: var=$(wslpath -w .); echo $var
C: mp
cmd.exe /c "$var # will error
How do I capture the output of wslpath
into a valid variable without formatting the escape characters ?
(I hope I am using the right terminology here. Please correct me if not.)