aboutsummaryrefslogtreecommitdiff
path: root/contrib/less/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/less/main.c')
-rw-r--r--contrib/less/main.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/contrib/less/main.c b/contrib/less/main.c
index 26c8d514e7fd..36a230e36ac8 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')