Merge branch 'scriptreplay_noisatty' of https://github.com/8vasu/util-linux
This commit is contained in:
commit
fbc9b69151
|
@ -109,7 +109,8 @@ delay_for(struct timeval *delay)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void appendchr(char *buf, size_t bufsz, int c)
|
static void
|
||||||
|
appendchr(char *buf, size_t bufsz, int c)
|
||||||
{
|
{
|
||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
|
@ -121,20 +122,22 @@ static void appendchr(char *buf, size_t bufsz, int c)
|
||||||
buf[sz] = c;
|
buf[sz] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int termraw(struct termios *backup)
|
static int
|
||||||
|
setterm(struct termios *backup)
|
||||||
{
|
{
|
||||||
struct termios tattr;
|
struct termios tattr;
|
||||||
|
|
||||||
if (tcgetattr(STDOUT_FILENO, backup) != 0)
|
if (tcgetattr(STDOUT_FILENO, backup) != 0) {
|
||||||
return -1;
|
if (errno == EBADF)
|
||||||
|
err(EXIT_FAILURE, _("%d not valid fd"), STDOUT_FILENO);
|
||||||
|
/* errno == ENOTTY */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
tattr = *backup;
|
tattr = *backup;
|
||||||
cfmakeraw(&tattr);
|
cfmakeraw(&tattr);
|
||||||
tattr.c_lflag |= ISIG;
|
tattr.c_lflag |= ISIG;
|
||||||
if (tcsetattr(STDOUT_FILENO, TCSANOW, &tattr) != 0)
|
tcsetattr(STDOUT_FILENO, TCSANOW, &tattr);
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -143,7 +146,7 @@ main(int argc, char *argv[])
|
||||||
static const struct timeval mindelay = { .tv_sec = 0, .tv_usec = 100 };
|
static const struct timeval mindelay = { .tv_sec = 0, .tv_usec = 100 };
|
||||||
struct timeval maxdelay;
|
struct timeval maxdelay;
|
||||||
|
|
||||||
char isterm;
|
int isterm;
|
||||||
struct termios saved;
|
struct termios saved;
|
||||||
|
|
||||||
struct replay_setup *setup = NULL;
|
struct replay_setup *setup = NULL;
|
||||||
|
@ -306,9 +309,7 @@ main(int argc, char *argv[])
|
||||||
replay_set_delay_max(setup, &maxdelay);
|
replay_set_delay_max(setup, &maxdelay);
|
||||||
replay_set_delay_min(setup, &mindelay);
|
replay_set_delay_min(setup, &mindelay);
|
||||||
|
|
||||||
isterm = isatty(STDOUT_FILENO);
|
isterm = setterm(&saved);
|
||||||
if (isterm && termraw(&saved) != 0)
|
|
||||||
err(EXIT_FAILURE, _("failed to set terminal to raw mode"));
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
rc = replay_get_next_step(setup, streams, &step);
|
rc = replay_get_next_step(setup, streams, &step);
|
||||||
|
|
Loading…
Reference in New Issue