* Carsten Hey [2015-07-28 16:11 +0200]:
This is a .bash_logout problem, the code below fixes this.
This is actually a clear_console problem, the code below works around
this, and if clear_console would do what it should, it would still be
a significant performance improvement.
Maybe you should throw away clear_console and replace it with a simple
shell script that runs getopts, prints the message known from
clear_console if -q is not used and no terminal was detected (I would
have added a -v option instead and made -q default) and contains the
inner case snippet from the code below.
Use "${VAR-}", not "$VAR" and add "&& :" to commands that could fail.
Also fixed below.
Unless noted otherwise, anything below is too trivial to be
copyrightable.
# The author of the “if [ "$SHLVL" = 1 ]; then” part of below condition
# is Matthias Klose, see /usr/share/doc/bash/copyright on Debian or
# Ubuntu for copyright and license information.
if [ "${SHLVL-}|${SSH_CONNECTION-}" = "1|" ]; then
case ${0##*/} in
(-su|su)
;;
(*)
# This is a replacement for console_clear, which is broken.
# After console_clear has been rewritten, it will be able to
# replace below code.
#
# The glob to detect consoles below is:
# Copyright (C) 2011 Anton Zinoviev, and published under
# the license terms found in /usr/share/doc/expat/copyright,
# commonly known as MIT license.
if [ -x /usr/bin/tty ]; then
case $(/usr/bin/tty) in
(/dev/tty[1-9]*|/dev/vc/[0-9]*|/dev/console|/dev/ttyv[0-9]*)
[ -x /usr/bin/clear ] && /usr/bin/clear && :
;;
esac
fi
;;
esac
fi
: