PHP -r "readfile('https://getcomposer.org/installer');" | PHP
$PHP -r "readfile('https://getcomposer.org/installer');" | PHP output is not a tty input is not a tty
我在Windows 7中并使用git bash来执行此命令.在Windows命令提示符下,它工作正常.只有从git bash 2.6.2-64bit运行此命令时才会出现此问题.
顺便说一下,我已经为windows安装了composer,这很好用.但我无法以这种方式下载composer.phar.我该如何解决这个问题?
> issue 25提到:
it seems that
git ls-remote origin
,run from a freshly-built and installed MinGW Git fails to be able to output anything,andgit ls-remote origin | cat
(a trick learned from working with old MSys’/MinGW’s quirks) only says:output is not a tty
(the exit code is 127,suggesting that some executable was not found,but it is very difficult to say which one because not even debug print statements to stderr are shown; It seems that in case of a crash or of a die(),stderr is not flushed)
> issue 519甚至建议unalias winpty
unalias $(alias | grep winpty | cut -d"=" -f1 | cut -d" " -f2)
但:
No,we cannot simply abandon winpty. PHP can be run interactively,i.e. it requires a proper Win32 Console. Running PHP without winpty in MinTTY would not provide that Console instance,leaving you with a seemingly unresponsive terminal.
See 07002,07003 and 07004 to understand what havoc you would wreak by simply removing those aliases.
所以现在,bash控制台与通过管道执行PHP不兼容(因为第二个| PHP可能无法从winpty中受益,这在程序需要Win32控制台进行交互式使用时似乎需要).
If you use C:`Program Files\Git\bin\bash.exe
instead of
C:\Program Files\Git\git-bash.exe`,then the command works fine.
I’m using it in combination with 07007 without any problems
这可能是因为bash.exe不使用winpty,与git-bash.exe相反.