From: Karel Zak Date: Mon, 17 Mar 2025 10:49:57 +0000 (+0100) Subject: more: fix repeat command X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5be4bdf81a8e89b98b12db275deb6154f87feb4b;p=thirdparty%2Futil-linux.git more: fix repeat command The function more_key_command() may modify the current command setting. We need to remember the original unmodified version, as specified by the user, as the previous command; otherwise, the output will be affected by unexpected cmd.number settings. Simple reproducer: $ more -c /etc/passwd - Press to jump to the next line. - Press '.' to repeat the last command. Old version: - It clears the screen and prints only one line (like the "1 " command). Fixed version: - It jumps to the next line (like the "" command). Reported-by: Benno Schulenberg Signed-off-by: Karel Zak --- diff --git a/text-utils/more.c b/text-utils/more.c index 48f27f9e9..a035591af 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -1684,6 +1684,9 @@ static int more_key_command(struct more_control *ctl, char *filename) continue; if (cmd.key == more_kc_repeat_previous) cmd = ctl->previous_command; + else + ctl->previous_command = cmd; + switch (cmd.key) { case more_kc_backwards: if (ctl->no_tty_in) { @@ -1849,7 +1852,6 @@ static int more_key_command(struct more_control *ctl, char *filename) fflush(NULL); break; } - ctl->previous_command = cmd; if (done) { cmd.key = more_kc_unknown_command; break;