X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftput.c;h=295b83fb8161513a83697cf0ee9da2ff8c135af2;hp=76370cbcb74cc8cb3355da93d041d67a17935a03;hb=47d2fb4537d9ad5bb14f4810561a327930ca4280;hpb=cd142df6d9934f1bda19f5b968cc666291be5072 diff --git a/progs/tput.c b/progs/tput.c index 76370cbc..295b83fb 100644 --- a/progs/tput.c +++ b/progs/tput.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * + * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -50,7 +51,7 @@ #include #include -MODULE_ID("$Id: tput.c,v 1.77 2017/10/07 23:51:01 tom Exp $") +MODULE_ID("$Id: tput.c,v 1.81 2020/02/02 23:34:34 tom Exp $") #define PUTS(s) fputs(s, stdout) @@ -230,7 +231,7 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[]) * representations */ - for (k = 1; k < argc; k++) { + for (k = 1; (k < argc) && (k < NUM_PARM); k++) { char *tmp = 0; strings[k] = argv[k]; numbers[k] = strtol(argv[k], &tmp, 0); @@ -293,7 +294,7 @@ main(int argc, char **argv) term = getenv("TERM"); - while ((c = getopt(argc, argv, "ST:V")) != -1) { + while ((c = getopt(argc, argv, "ST:Vx")) != -1) { switch (c) { case 'S': cmdline = FALSE; @@ -316,7 +317,10 @@ main(int argc, char **argv) } is_alias = (is_clear || is_reset || is_init); - need_tty = (is_reset || is_init); + need_tty = ((is_reset || is_init) || + (optind < argc && + (!strcmp(argv[optind], "reset") || + !strcmp(argv[optind], "init")))); /* * Modify the argument list to omit the options we processed.