Behavior when Linux less ends depending on the connection source

Question

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.

Behavior I examined

Operation on Linux (when accessed from Hyper-V) (end with less / etc / crontab → q)

linux-min.gif You can confirm that the screen is not cleared and the displayed contents remain.

Operation of the terminal (when the terminal is launched from Teraterm or GUI) (same as above)

terminal.gif

If you access from Terminal, you can see that the screen is cleared at the end.

I found out by investigating

--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!)

Private conclusion

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

Behavior when Linux less ends depending on the connection source
About the --enable-shared option when building Python on Linux
rsync Behavior changes depending on the presence or absence of the slash in the copy source
Install the JDK on Linux
Paste the link on linux
Check the behavior when assigning Python
Hook to Shared Library on Linux to interrupt the behavior of existing binaries
Install scipy on Linux without internet connection
Behavior when returning in the with block
Notes on using OpenCL on Linux on the RX6800
Notify Slack when the linux command finishes
Compiling the Linux kernel (Linux 5.x on Ubuntu 20.04)
[Linux] Difference in time information depending on the clock ID of the clock_gettime () function
In Python, change the behavior of the method depending on how it is called
The day when the flask server running on linux on AWS was semi-persistent (running in the background)
I want to be notified when the command operation is completed on linux!