Description of problem: By default, "journalctl" invokes a pager when viewing a log, and the default pager is "less". The problem is that the mouse scroll wheel scrolls the terminal window instead of the log file itself. Version-Release number of selected component (if applicable): systemd-239-6.git9f3aed1.fc29.x86_64 less-530-2.fc29.x86_64 How reproducible: Always. Also occurs with F28. Steps to Reproduce: Case 1: 1. Open a terminal window. 2. $ echo foo # provide a visible reference point in the terminal window 3. $ journalctl -b 4. With the pointer in the terminal window, move the mouse scroll wheel in both directions. 5. Press "q" to quit. Case 2: 6. $ journalctl -b --no-pager | less 7. With the pointer in the terminal window, move the mouse scroll wheel in both directions. 8. Press "q" to quit. Case 3: 9. $ journalctl -b --no-pager | less -X 10. With the pointer in the terminal window, move the mouse scroll wheel in both directions. 11. Press "q" to quit. Actual results: In case 1 and case 3, the terminal window is scrolled. In case 2, the log is scrolled. Expected results: Case 1 and case 2 have identical behavior. Additional info: The "-X" option is being passed to "less", according to the "journalctl" man page: $SYSTEMD_LESS Override the options passed to less (by default "FRSXMK"). Verify that no relevant environment variables are set with: $ env | egrep '(LESS|PAGER)' LESSOPEN=||/usr/bin/lesspipe.sh %s
(In reply to Steve from comment #0) ... > The "-X" option is being passed to "less", according to the "journalctl" man > page: > > $SYSTEMD_LESS > Override the options passed to less (by default "FRSXMK"). Some of those "less" options might be justifiably used with "journalctl", but it would be better to set them overtly in the environment or a configuration file, instead of hard-coding them: $ less -N systemd-238/src/shared/pager.c ... 62 int pager_open(bool no_pager, bool jump_to_end) { ... 106 /* Initialize a good set of less options */ 107 less_opts = getenv("SYSTEMD_LESS"); 108 if (!less_opts) 109 less_opts = "FRSXMK"; 110 if (jump_to_end) 111 less_opts = strjoina(less_opts, " +G"); ...
(In reply to Steve from comment #1) ... > ... it would be better to set them overtly in the environment or a > configuration file, instead of hard-coding them: ... The default "less" options do not appear to be documented in any "systemd" config file: $ grep -i less /etc/systemd/*.conf | grep -v GNU
(In reply to Steve from comment #1) > (In reply to Steve from comment #0) > ... > > The "-X" option is being passed to "less", according to the "journalctl" man > > page: > > > > $SYSTEMD_LESS > > Override the options passed to less (by default "FRSXMK"). > > Some of those "less" options might be justifiably used with "journalctl", > but it would be better to set them overtly in the environment or a > configuration file, instead of hard-coding them: So, you first show the environment variable where the options are set, and then say the options are hard-coded... SYSTEMD_LESS is *the* environment option to change the options. It's documented in systemctl(1) and journalctl(1).
(In reply to Jan Synacek from comment #3) ... > So, you first show the environment variable where the options are set, and > then say the options are hard-coded... SYSTEMD_LESS is *the* environment > option to change the options. It's documented in systemctl(1) and > journalctl(1). Good catch. I should have said that "it would be better to set them [the default "less" options] overtly in ... a configuration file" instead of in the code. Subsequently, I remembered that the "systemd" convention is to document the defaults in a config file: $ less /etc/systemd/journald.conf ... # Entries in this file show the compile time defaults. ... Anyway, is there any reason to set the "-X" "less" option? For comparison, the "man" command doesn't set any "less" options: $ strace -f -o x1.log man date $ less x1.log ... 2323 execve("/usr/bin/less", ["less"], 0x55a5de9cf0b0 /* 57 vars */ <unfinished ...> ...
(In reply to Steve from comment #4) ... > For comparison, the "man" command doesn't set any "less" options: ... Correcting myself. The options are passed in the environment. However, the "-X" option is not one of the options: $ strace -f -v -o x2.log man date $ less x2.log ... 3270 execve("/usr/bin/less", ["less"], [ ... "LESS=-ix8RmPm Manual page date(1"..., "MAN_PN=date(1)"] <unfinished ...> ... The "-P" option might actually be a good addition to the "less" options passed by "journalctl": less(1): "The -P option allows you to tailor the prompt to your preference. ..."
(In reply to Steve from comment #4) > Anyway, is there any reason to set the "-X" "less" option? I don't know. I traced the original commit that added support for the external pager to https://github.com/systemd/systemd/commit/0736af98c6fae9c7d31e3dd17589421b7e883ef5, but no documentation about the less options can be found there. I guess the best course of action would be to ask on the systemd-devel mailing list.
(In reply to Jan Synacek from comment #6) > (In reply to Steve from comment #4) > > Anyway, is there any reason to set the "-X" "less" option? > > I don't know. I traced the original commit that added support for the > external pager to > https://github.com/systemd/systemd/commit/ > 0736af98c6fae9c7d31e3dd17589421b7e883ef5, but no documentation about the > less options can be found there. I guess the best course of action would be > to ask on the systemd-devel mailing list. Thanks for posting that commit. The change to the "TODO" file provides a clue: "- * systemctl auto-pager a la git" git-config(1): "When the LESS environment variable is unset, Git sets it to FRX ..." So, the "-X" "less" option appears to have been *copied* from the git code ...
For the record, this is a workaround for this bug: $ SYSTEMD_LESS='FRSMK' journalctl -b # remove "-X" option, retain other options
(In reply to Steve from comment #8) > For the record, this is a workaround for this bug: > > $ SYSTEMD_LESS='FRSMK' journalctl -b # remove "-X" option, retain other > options Here is a difference in behavior: Scrolls the terminal window before displaying the log text: $ journalctl -b -n 6 Blanks the terminal window before displaying the log text: $ SYSTEMD_LESS='FRSMK' journalctl -b -n 6 The latter behavior is the same as that of the "man" command with a short man page: $ man 7 intro # run in a full-screen terminal window
The reason why 'X' is passed is that we want stuff like 'journalctl -n5' to print stuff to the console just like 'tail -n5' would. If 'X' is removed from the options, less output is only visible when less is running, and gone afterwards. We could try to be smart and add 'X' only in certain circumstances, e.g. when '-n' is given and such, but this would be quite confusing, because the pager behaviour would be substantially different based on some (seemingly unrelated) options. So sorry, this isn't really a bug, but a limitation of less, or maybe even the terminal. Thinking about this some more, it seems likely that it simply isn't possible to do "output to the console but scroll with the mouse". Users may override this if they wish (as described in the comments above), but the current default should stay. https://github.com/systemd/systemd/pull/13126
Docs were improved in the PR above, now in rawhide.