wsl-alias
wsl-alias copied to clipboard
Arguments not translated correctly
Hi,
I'm running v2.3 on Windows 10 x64 1803 with Debian installed in WSL and I installed wsl-alias using the provided installer. I've encountered several problems.
I've added an alias for php like this:
C:\Users\Me>b wsl-alias add php php
To verify it really is running from WSL:
C:\Users\Me>php -a
Interactive mode enabled
php > system("uname");
Linux
Running files using a relative path works:
C:\Users\Me>php Documents\Projects\test.php
Using a full path however, does not:
C:\Users\Me>php C:\Users\Me\Documents\Projects\test.php
Could not open input file: C:/Users/Me/Documents/Projects/test.php
Also, some special characters in arguments cause problems. Parantheses will not work:
C:\Users\Me>php -r "exit()"
/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `~/.wsl-alias/wrapper.sh 'C:\\Users\\Me' php -r \"exit()\"'
Semicolons will also cause errors:
C:\Users\Me>php -r "exit;"
/home/me/.wsl-alias/wrapper.sh: eval: line 41: unexpected EOF while looking for matching `"'
/home/me/.wsl-alias/wrapper.sh: eval: line 42: syntax error: unexpected end of file
Let me know if I can be of any help.
EDIT: For clarification, running these commands without wsl-alias using only the native wsl, all special characters work:
C:\Users\Me>wsl php -r "printf('Test(\"Test\");');"
Test("Test");
Hello and thanks for your detailed description of the problem! I'm unfortunately aware of the issue, however I'm not really sure what I can do to fix this behavior.
The problem originates in the different ways cmd and powershell interpret arguments passed to a script and wsl-alias trying to be maximally compatible with both. I noticed you're using cmd, and if you tried running the last command in your issue in powershell, it wouldn't work because powershell ommits the first doubleqoutes from the params..
I am still quite unsure about how to approach this problem - I could remove powershell escaping support and extend the cmd syntax support (to match the native wsl
command behavior) or keep it this way with limited functionality in both ps and cmd..