only set the console mode if stdin is a console (not a pipe)
This allows piping commands and running from a cygwin console.
This commit is contained in:
parent
75ef5bb160
commit
afcc027da7
@ -301,27 +301,39 @@ open_console(UI *ui)
|
|||||||
tty_in = stdin;
|
tty_in = stdin;
|
||||||
tty_out = stderr;
|
tty_out = stderr;
|
||||||
|
|
||||||
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO);
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE) {
|
||||||
return GetConsoleMode(handle, &console_mode);
|
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
||||||
|
return GetConsoleMode(handle, &console_mode);
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
noecho_console(UI *ui)
|
noecho_console(UI *ui)
|
||||||
{
|
{
|
||||||
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO);
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE) {
|
||||||
return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT);
|
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
||||||
|
return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT);
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
echo_console(UI *ui)
|
echo_console(UI *ui)
|
||||||
{
|
{
|
||||||
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO);
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE) {
|
||||||
return SetConsoleMode(handle, console_mode);
|
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
||||||
|
return SetConsoleMode(handle, console_mode);
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user