diff options
author | delphij <delphij@FreeBSD.org> | 2007-06-04 01:42:54 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2007-06-04 01:42:54 +0000 |
commit | 7672cb6e48e2ed472cbd72caaa0eb155608a644d (patch) | |
tree | ee770081db4ef1d4b6022e0608a222ea35319caa /contrib/less/main.c | |
parent | 5297f4bc59da861bbe3beb5ee12839fa05e79882 (diff) | |
download | FreeBSD-src-7672cb6e48e2ed472cbd72caaa0eb155608a644d.zip FreeBSD-src-7672cb6e48e2ed472cbd72caaa0eb155608a644d.tar.gz |
/home/delphij/m
Diffstat (limited to 'contrib/less/main.c')
-rw-r--r-- | contrib/less/main.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/contrib/less/main.c b/contrib/less/main.c index 26c8d51..36a230e 100644 --- a/contrib/less/main.c +++ b/contrib/less/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2004 Mark Nudelman + * Copyright (C) 1984-2007 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -32,6 +32,7 @@ public char * progname; public int quitting; public int secure; public int dohelp; +public int less_is_more; #if LOGFILE public int logfile = -1; @@ -56,6 +57,8 @@ static char consoleTitle[256]; extern int missing_cap; extern int know_dumb; +extern int quit_if_one_screen; +extern int pr_type; /* @@ -111,12 +114,26 @@ main(argc, argv) is_tty = isatty(1); get_term(); init_cmds(); - init_prompt(); init_charset(); init_line(); init_cmdhist(); init_option(); - s = lgetenv("LESS"); + + /* + * If the name of the executable program is "more", + * act like LESS_IS_MORE is set. + */ + for (s = progname + strlen(progname); s > progname; s--) + { + if (s[-1] == PATHNAME_SEP[0]) + break; + } + if (strcmp(s, "more") == 0) + less_is_more = 1; + + init_prompt(); + + s = lgetenv(less_is_more ? "MORE" : "LESS"); if (s != NULL) scan_option(save(s)); @@ -141,6 +158,9 @@ main(argc, argv) quit(QUIT_OK); } + if (less_is_more && get_quit_at_eof()) + quit_if_one_screen = TRUE; + #if EDITOR editor = lgetenv("VISUAL"); if (editor == NULL || *editor == '\0') |