Skip to content

Instantly share code, notes, and snippets.

@stmoerman
Last active September 22, 2018 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stmoerman/8f9e38363ea77937fe8c3e8cc31a55d4 to your computer and use it in GitHub Desktop.
Save stmoerman/8f9e38363ea77937fe8c3e8cc31a55d4 to your computer and use it in GitHub Desktop.
@echo OFF
setlocal ENABLEDELAYEDEXPANSION
rem Collect the arguments and replace:
rem '\' with '/'
rem 'c:' with 'mnt/c'
rem '"' with '\"'
set v_params=%*
set v_params=%v_params:\=/%
set v_params=%v_params:C:=/mnt/c%
set v_params=%v_params%
set v_params=%v_params:"=\"%
rem Call the windows-php inside WSL.
rem windows-php is just a script which passes the arguments onto
rem the original php executable and converts its output from UNIX
rem syntax to Windows syntax.
C:\Windows\system32\bash.exe -l -c "windows-php %v_params%"
"php.validate.executablePath": "c:\\wsl-tools\\php.bat"
# place this file in /usr/local/bin
# Pass all the arguments to PHP.
output=$(php "$@")
# Perform UNIX->WINDOWS syntax replacements.
output="${output//$'\n'/$'\r'$'\n'}"
output="${output//\/mnt\/c/C:}"
output="${output//\//\\}"
# Echo corrected output.
echo $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment