dan@rna.UUCP (Dan Ts'o) (08/27/85)
x Here are a few more fixes to the LESS pager posted several weeks ago. - A bug in the -s option, reported by unm-la!jay, is fixed. - Shell escapes get the terminal as standard input. - Hitting EOF twice on short files didn't exit, it now does. - ^L, ^R, synonyms for r, repaint screen. Cheers, Dan Ts'o Dept. Neurobiology Rockefeller Univ. 1230 York Ave. NY, NY 10021 212-570-7671 ...cmcl2!rna!dan rna!dan@cmcl2.arpa *** prim.c.old Tue Aug 27 14:20:44 1985 --- prim.c Tue Aug 27 14:21:21 1985 *************** *** 37,44 * End of file: stop here unless the top line * is still empty, or "force" is true. */ - if (!force && position(TOP) != NULL_POSITION) - { #ifdef EOFQUIT eofquit++; #endif --- 37,42 ----- * End of file: stop here unless the top line * is still empty, or "force" is true. */ #ifdef EOFQUIT eofquit++; #endif *************** *** 40,46 if (!force && position(TOP) != NULL_POSITION) { #ifdef EOFQUIT ! eofquit++; #endif if (quiet == NOT_QUIET) bell(); --- 38,44 ----- * is still empty, or "force" is true. */ #ifdef EOFQUIT ! eofquit++; #endif if (!force && position(TOP) != NULL_POSITION) { *************** *** 42,47 #ifdef EOFQUIT eofquit++; #endif if (quiet == NOT_QUIET) bell(); else --- 40,47 ----- #ifdef EOFQUIT eofquit++; #endif + if (!force && position(TOP) != NULL_POSITION) + { if (quiet == NOT_QUIET) bell(); else *** help.c.org Mon Jul 22 14:19:20 1985 --- help.c Tue Aug 27 14:23:55 1985 *************** *** 11,19 puts("b Backward one screen.\n"); puts("e, j, CR * Forward N lines, default 1.\n"); puts("y, k * Backward N lines, default 1.\n"); puts("d, ^D * Forward N lines, default 10 or last N to d or u command.\n"); puts("u, ^U * Backward N lines, default 10 or last N to d or u command.\n"); ! puts("r Repaint screen.\n"); puts("g * Go to line N, default 1.\n"); puts("G * Like g, but default is last line in file.\n"); puts("= Print current file name\n"); --- 15,23 ----- puts("e, j, CR * Forward N lines, default 1.\n"); #endif puts("y, k * Backward N lines, default 1.\n"); puts("d, ^D * Forward N lines, default 10 or last N to d or u command.\n"); puts("u, ^U * Backward N lines, default 10 or last N to d or u command.\n"); ! puts("r, ^L, ^R Repaint screen.\n"); puts("g * Go to line N, default 1.\n"); puts("G * Like g, but default is last line in file.\n"); puts("= Print current file name\n"); *** ch.c.old Fri Aug 23 01:30:50 1985 --- ch.c Fri Aug 23 01:26:37 1985 *************** *** 84,90 */ bp = buf_tail; bp->block = ch_block; ! if (pipe) { /* * The block requested should be one more than --- 84,90 ----- */ bp = buf_tail; bp->block = ch_block; ! if (pipe || sflag) { /* * The block requested should be one more than *************** *** 221,227 public POSITION ch_length() { ! if (pipe) return (NULL_POSITION); return ((POSITION)(lseek(file, (off_t)0, 2))); } --- 221,227 ----- public POSITION ch_length() { ! if (pipe || sflag) return (NULL_POSITION); return ((POSITION)(lseek(file, (off_t)0, 2))); } *** command.c.old Sun Aug 25 21:56:52 1985 --- command.c Sun Aug 25 22:21:01 1985 *************** *** 3,8 */ #include "less.h" extern int erase_char, kill_char; extern int pr_type; --- 3,9 ----- */ #include "less.h" + #include <signal.h> extern int erase_char, kill_char; extern int pr_type; *************** *** 270,276 putc('\n'); flush(); raw_mode(0); ! system(cmdbuf); raw_mode(1); error("!done"); first_cmd = "r"; /* Repaint */ --- 271,277 ----- putc('\n'); flush(); raw_mode(0); ! shell(cmdbuf); raw_mode(1); error("!done"); first_cmd = "r"; /* Repaint */ *************** *** 601,604 } } } } --- 602,641 ----- } } } + } + + shell(s) + char *s; + { + int status, pid, w; + register int (*istat)(), (*qstat)(); + register char *sh; + extern int tty; + + #ifdef VFORK + if ((pid = vfork()) == 0) { + #else + if ((pid = fork()) == 0) { + #endif + signal(SIGINT, SIG_DFL); + signal(SIGQUIT, SIG_DFL); + /* special less code */ + close(0); + dup(tty); + for (pid = 3; pid < 30; close(pid++)); + sh = getenv("SHELL"); + if (sh && *sh) + execl(sh, "sh", "-c", s, 0); + execl("/bin/sh", "sh", "-c", s, 0); + _exit(127); + } + istat = signal(SIGINT, SIG_IGN); + qstat = signal(SIGQUIT, SIG_IGN); + while ((w = wait(&status)) != pid && w != -1) + ; + if (w == -1) + status = -1; + signal(SIGINT, istat); + signal(SIGQUIT, qstat); + return(status); } *** command.c.old Tue Aug 27 14:55:13 1985 --- command.c Tue Aug 27 14:55:16 1985 *************** *** 308,314 } else { #ifdef EOFQUIT intrquit = 0; ! if (strchr(" fdj\006\026", c) == 0) eofquit = 0; else if (eofquit) { eofquit = 0; --- 308,314 ----- } else { #ifdef EOFQUIT intrquit = 0; ! if (strchr(" fdj\006\026\n\r\004", c) == 0) eofquit = 0; else if (eofquit) { eofquit = 0; *** less.l.old Mon Aug 26 18:05:07 1985 --- less.l Tue Aug 27 14:30:32 1985 *************** *** 79,84 .IP r Repaint the screen. .PP .IP R Repaint the screen, discarding any buffered input. Useful if the file is changing while it is being viewed. --- 79,87 ----- .IP r Repaint the screen. .PP + .IP "^L, ^R" + Same as r. + .PP .IP R Repaint the screen, discarding any buffered input. Useful if the file is changing while it is being viewed.