It really had no need to be a global process flag at all: it's used to
signal to uxcons.c that stderr_tty_init() ought to check whether
stderr is a tty (in order to save its termios across interactive
prompts and so forth). But the only _caller_ of stderr_tty_init is
Unix Plink, which always sets that flag! So we already have a
perfectly good system for signalling to uxcons.c that you'd like
stderr_tty_init to do something: _whether you call it or not_.
This commit is contained in:
Simon Tatham 2020-01-30 06:40:21 +00:00
Родитель dc59fcf8e3
Коммит 6e85d3fe60
3 изменённых файлов: 3 добавлений и 15 удалений

Просмотреть файл

@ -101,18 +101,6 @@ unsigned long getticks(void);
#define WCHAR wchar_t
#define BYTE unsigned char
/*
* Unix-specific global flag
*
* FLAG_STDERR_TTY indicates that standard error might be a terminal and
* might get its configuration munged, so anything trying to output plain
* text (i.e. with newlines in it) will need to put it back into cooked
* mode first. Applications setting this flag should also call
* stderr_tty_init() before messing with any terminal modes, and can call
* premsg() before outputting text to stderr and postmsg() afterwards.
*/
#define FLAG_STDERR_TTY 0x1000
#define PLATFORM_CLIPBOARDS(X) \
X(CLIP_PRIMARY, "X11 primary selection") \
X(CLIP_CLIPBOARD, "XDG clipboard") \
@ -305,7 +293,7 @@ extern char *pty_osx_envrestore_prefix;
/* Things provided by uxcons.c */
struct termios;
void stderr_tty_init(void);
void stderr_tty_init(void); /* call at startup if stderr might be a tty */
void premsg(struct termios *);
void postmsg(struct termios *);

Просмотреть файл

@ -26,7 +26,7 @@ static bool stderr_is_a_tty;
void stderr_tty_init()
{
/* Ensure that if stderr is a tty, we can get it back to a sane state. */
if ((flags & FLAG_STDERR_TTY) && isatty(STDERR_FILENO)) {
if (isatty(STDERR_FILENO)) {
stderr_is_a_tty = true;
tcgetattr(STDERR_FILENO, &orig_termios_stderr);
}

Просмотреть файл

@ -603,7 +603,7 @@ int main(int argc, char **argv)
stderr_bs = BinarySink_UPCAST(&stderr_bcs);
outgoingeof = EOF_NO;
flags = FLAG_STDERR_TTY;
flags = 0;
cmdline_tooltype |=
(TOOLTYPE_HOST_ARG |
TOOLTYPE_HOST_ARG_CAN_BE_SESSION |