I'm on WSL (windows subsystem for Linux) I'm trying to create an alias to run vswhere.exe, which will tell me where devenv.exe is located, and then run that from my ZSH shell.
path1="$(vswhere.exe -property productPath -format value)"
echo $path1
outputs: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe
path2=$(wslpath -a "$path1")
echo $path2
outputs: /mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/devenv.exe
$path2 contains exactly what i want to execute, except it's not quoted. If I take that string on the console, copy paste it, and surround it with quotes manually, VS executes properly.
Like this: eval '/mnt/c/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2017/Enterprise/Common7/IDE/devenv.exe'
running: eval $path2 fails since the $path2 has spaces in it.
I've tried this: path3=$(printf %q $path2 | sed -e 's/^M$//')
echo $path3
'mnt/c/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2017/Enterprise/Common7/IDE/devenv.exe$'
This contains a $ at the end of the string. Trying to do eval $path3 fails with:
zsh: no such file or directory: /mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/devenv.exe^M
Note the ^M at the end. I've run out of ideas on sed commands and such to make this work and I'm sure there's just some fancy regex or zsh/bash command to make this work properly.