I'm trying to create a script so I can use it with windows open-with in file explorer, it's supposed to pass the filenames to emacs but here is the problem:
Emacs.bat:
```
wsl bash -c ". ~/.bash_profile && emacs %*"
```
(. bash\_profile is needed to export variables for x server to work properly)
%* is expanded to windows style filenames with \\ instead of /
I tried to work around this by passing these arguments to bash script:
Emacs.bat:
```
wsl bash -c ". ~/.bash_profile && ~/.emacs.d/windows-open %*"
```
windows-open:
```
#!/bin/sh
echo "$@" | tr '\\' '/' # see how it expands
# emacs $(echo "$@" | tr '\\' '/')
```
and trying to run:
```
PS C:\Users\wisni> .\bin\Emacs.bat "te\st lmao"
C:\Users\wisni>wsl bash -c ". ~/.bash_profile && ~/.emacs.d/windows-open "te\st lmao""
test
```
as you can see only the first word of was passed to the script (te\st) and \s was somehow escaped by the shell to just s.
I had tried to use single quote instead of double quotes:
```
wsl bash -c '. ~/.bash_profile && ~/.emacs.d/windows-open %*'
```
but it breaks even more badly:
```
PS C:\Users\wisni> .\bin\Emacs.bat "te\st lmao"
C:\Users\wisni>wsl bash -c '. ~/.bash_profile && ~/.emacs.d/windows-open "te\st lmao"'
/bin/bash: -c: line 0: unexpected EOF while looking for matching `''
/bin/bash: -c: line 1: syntax error: unexpected end of file
```
any idea how to do it?