- for (n = optind; n < argc; ++n) {
- setupterm((NCURSES_CONST char *) argv[n], 1, (int *) 0);
- terms[n - optind] = cur_term;
+ if (optind < argc) {
+ int found = 0;
+ int status;
+ for (n = optind; n < argc; ++n) {
+ setupterm((NCURSES_CONST char *) argv[n], 1, &status);
+ if (status > 0 && cur_term != 0) {
+ terms[found++] = cur_term;
+ }
+ }
+ if (found)
+ list_keys(terms, found);
+ } else {
+ setupterm(NULL, 1, (int *) 0);
+ terms[0] = cur_term;
+ list_keys(terms, 1);