X-Git-Url: http://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=progs%2Ftset.c;h=8bc502a36967b7afeabe4709ca3641b893262106;hb=75a9c36c205ebefe07580acd0b1053a2abbd44b9;hp=a7fdd5ed58825deccb4cf0995ddbfc703bfd6250;hpb=c2650100f80134924eda8f22cd7cc1d1d919ee3d;p=ncurses.git diff --git a/progs/tset.c b/progs/tset.c index a7fdd5ed..8bc502a3 100644 --- a/progs/tset.c +++ b/progs/tset.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 2020-2021,2024 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -91,14 +91,14 @@ #include #include -#if HAVE_GETTTYNAM && HAVE_TTYENT_H +#if HAVE_GETTTYNAM #include #endif #ifdef NeXT char *ttyname(int fd); #endif -MODULE_ID("$Id: tset.c,v 1.127 2021/03/20 18:01:34 tom Exp $") +MODULE_ID("$Id: tset.c,v 1.134 2024/04/13 18:59:53 tom Exp $") #ifndef environ extern char **environ; @@ -167,7 +167,6 @@ static const char * askuser(const char *dflt) { static char answer[256]; - char *p; /* We can get recalled; if so, don't continue uselessly. */ clearerr(stdin); @@ -176,7 +175,10 @@ askuser(const char *dflt) exit_error(); /* NOTREACHED */ } + for (;;) { + char *p; + if (dflt) (void) fprintf(stderr, "Terminal type? [%s] ", dflt); else @@ -543,12 +545,14 @@ get_termcap_entry(int fd, char *userarg) int errret; char *p; const char *ttype; +#if HAVE_PATH_TTYS #if HAVE_GETTTYNAM struct ttyent *t; #else FILE *fp; #endif char *ttypath; +#endif /* HAVE_PATH_TTYS */ (void) fd; @@ -561,6 +565,7 @@ get_termcap_entry(int fd, char *userarg) if ((ttype = getenv("TERM")) != 0) goto map; +#if HAVE_PATH_TTYS if ((ttypath = ttyname(fd)) != 0) { p = _nc_basename(ttypath); #if HAVE_GETTTYNAM @@ -598,6 +603,7 @@ get_termcap_entry(int fd, char *userarg) } #endif /* HAVE_GETTTYNAM */ } +#endif /* HAVE_PATH_TTYS */ /* If still undefined, use "unknown". */ ttype = "unknown"; @@ -773,6 +779,7 @@ main(int argc, char **argv) bool opt_w = FALSE; /* set window-size */ TTY mode, oldmode; + _nc_progname = _nc_rootname(*argv); obsolete(argv); noinit = noset = quiet = Sflag = sflag = showterm = 0; while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:p:qQrSsVw")) != -1) { @@ -831,7 +838,6 @@ main(int argc, char **argv) } } - _nc_progname = _nc_rootname(*argv); argc -= optind; argv += optind; @@ -853,7 +859,7 @@ main(int argc, char **argv) if (same_program(_nc_progname, PROG_RESET)) { reset_start(stderr, TRUE, FALSE); - reset_tty_settings(my_fd, &mode); + reset_tty_settings(my_fd, &mode, noset); } else { reset_start(stderr, FALSE, TRUE); } @@ -872,9 +878,13 @@ main(int argc, char **argv) if (!noinit) { if (send_init_strings(my_fd, &oldmode)) { + const char *name; + (void) putc('\r', stderr); (void) fflush(stderr); - (void) napms(1000); /* Settle the terminal. */ + if (IsRealTty(my_fd, name)) { + (void) napms(1000); /* Settle the terminal. */ + } } }