formulahendry/vscode-code-runner

Bash on Ubuntu on Windows php problem

開放

#105 建立於 2017年4月18日

 (3 則留言) (0 個反應) (0 位負責人)TypeScript (343 個分叉)github user discovery
help wanted

倉庫指標

星標
 (2,408 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

I've tried using PHP, installed in the Ubuntu subsystem on Windows 10, but it works partially.

I create the php.cmd file in PATH, which redirects the PHP command from the command line to bash Ubuntu (after replacing C:\ with /mnt/c/, replacing \ with / and escaping " characters). php.cmd:

@ECHO off
SET cmd=%*
SET cmd=%cmd:C:\=/mnt/c/%
SET cmd=%cmd:\=/%
SET cmd=%cmd:"=\"%
SET cmd=C:\Windows\System32\bash.exe -c "php %cmd%"
CALL %cmd%

This allows me to call from the command line (Windows) any php command (php -v; php "path_to_file"). However, this does not work with the code-runner, it outputs:

[Running] php "c:\temp\test.php"
"C:\Windows\System32\bash.exe" is not recognized as an internal or external command, 
operable program or batch file.

[Done] exited with code=1 in 0.028 seconds

In Windows shell (cmd, powershell) command php "c:\temp\test.php" works fine. What could be the reason?

貢獻者指南