[PATCH v2] less: respect -E (quit at EOF)

Aaro Koskinen aaro.koskinen at iki.fi
Wed Oct 16 19:31:50 UTC 2013


less displays -E in help text, but it's not doing anything. Make it quit
less when the last lines of the file have been printed.

Signed-off-by: Aaro Koskinen <aaro.koskinen at iki.fi>
---

Patch history:

	v2: Also check that EOF was reached (eof_error <= 0).

	v1: http://marc.info/?t=137910686900003&r=1&w=2


 miscutils/less.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/miscutils/less.c b/miscutils/less.c
index 60105f4..52ffead 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -795,6 +795,9 @@ static void buffer_print(void)
 			print_found(buffer[i]);
 		else
 			print_ascii(buffer[i]);
+	if ((option_mask32 & FLAG_E) && eof_error <= 0 &&
+	    (max_fline - cur_fline) <= max_displayed_line)
+		less_exit(EXIT_SUCCESS);
 	status_print();
 }
 
-- 
1.8.4.rc3



More information about the busybox mailing list