The officially official Devuan Forum!

You are not logged in.

#1 2023-02-14 16:34:19

From: UK
Registered: 2023-01-19
Posts: 57  

Is there a point to the default ~/.bash_logout file?

When setting up Devuan, Bash created /home/user/.bash_logout from /etc/skel/.bash_logout which ultimately seems to come from //

# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
    [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q

It only created this file for regular user (uid=1000), not the root user - I presume that's because root user existed before /etc/skel was populated, whilst regular user was added afterwards.

Seems to me that - if there's a privacy issue - it would apply to all users, so the logic belongs in a system-wide /etc/bash.bash.logout (mentioned in man bash, but doesn't exist on my system.)

However, when logging out of a TTY the screen clears for both root and regular user, even after renaming .bash_logout to disable it.

Anyhow know if there is some situation where this file is relevant, or is it a relic of ancient times that no longer applies?



#2 2023-02-14 17:47:42

From: London
Registered: 2019-03-24
Posts: 3,125  

Re: Is there a point to the default ~/.bash_logout file? … =%23331504

EDIT: agetty(8) clears the screen itself by default so presumably /etc/skel/.bash_logout was added when it didn't do that.

Last edited by Head_on_a_Stick (2023-02-14 18:28:11)

Brianna Ghey — Rest In Power


#3 2023-02-14 19:09:20

From: UK
Registered: 2023-01-19
Posts: 57  

Re: Is there a point to the default ~/.bash_logout file?

So it seems the reason it exists in user dir is "because someone asked for it and at that time nobody objected", and the reason it doesn't exist in root dir (or system-wide) is "because when others asked for that, there was disagreement on which program should do it".

I would have expected "login" do it, but since "man login" relinquishes responsibility for session clean up to getty, it seems sensible that that's where clearing the screen should be done.

The bug resolution has a note that console_clear acts on scrollback buffer, which has since been removed from the kernel, so I wonder if that was the reason it was originally needed, and thus appears to be redundant.

There's a comment in the relevant function for agetty suggesting this might be the case:

static void termio_clear(int fd)
	 * Do not write a full reset (ESC c) because this destroys
	 * the unicode mode again if the terminal was in unicode
	 * mode.  Also it clears the CONSOLE_MAGIC features which
	 * are required for some languages/console-fonts.
	 * Just put the cursor to the home position (ESC [ H),
	 * erase everything below the cursor (ESC [ J), and set the
	 * scrolling region to the full window (ESC [ r)
	write_all(fd, "\033[r\033[H\033[J", 9);

Reads like excuses for not fixing bugs. :/

Last edited by boughtonp (2023-02-14 19:10:07)



Board footer