When I tried to get started with Linux with the book "New Linux Textbook", some of the textbooks did not work and I did not find it. So I will leave it as a memorandum. Specifically, it is the usage example of "export command" in Chapter 08-04. In this chapter, set "--no-init" for the environment variable "LESS" and check the behavior change of the less command (the screen was cleared at the end, but the screen is not cleared). However, when I was connecting and operating from Hyper-V, the screen was not cleared even if I did not change the settings, and I did not understand why it did not follow the textbook. (I also checked alias, but there is no setting for less) So I'm a beginner, but I tried to find out what was the cause as much as I could.
You can confirm that the screen is not cleared and the displayed contents remain.
If you access from Terminal, you can see that the screen is cleared at the end.
--When I looked at the source of ~~ less, the screen was cleared when "is_tty" was True. This variable is set to "isatty (1)" and according to the documentation it seems to be "1" when connecting from a terminal. ~~
--~~ less source Applicable part: https://github.com/gwsw/less/blob/e27853c89be227ad7a1a81aefd2942c03bd32dad/main.c#L387 ~~
--~~ isatty manual ("1" seems to indicate standard output): https://linuxjm.osdn.jp/html/LDP_man-pages/man3/isatty.3.html~~
(2020/04/06: When I checked based on the comments I received, it was deleted because isatty (1) certainly returned "1" in both cases. Thank you @ angel_p_57!)
--I confirmed that the value of the environment variable $ TERM changes depending on how you log in.
--When connecting with Hyper-V: linux
--When starting a terminal from GUI or logging in from outside (with teraterm): xterm
――When I changed the above environment variable TERM, it became Linux-like behavior on Linux, and it became terminal-like behavior on Linux, so it seems to be related to ~~ isatty. It seems to work with ~~ $ TERM.
-When switching with $ TERM, the operation changes depending on whether "smcup" or "rmcup" is included in "terminal information (infocmp)".
(Corrected based on the comments received on 2020/04/06. Thank you @ angel_p_57!)
Since the above textbook is supposed to be executed in the terminal, in principle, it is better to run it in the terminal instead of accessing Linux directly.
Recommended Posts