25

I don't think that I have seen this before, but whenever I run exit in terminal I get a very strange output.

This is what it looks like:

logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

And when I remove ~/.bash_sessions I get this output.

logout
Saving session...-bash: ~/.bash_sessions/EBDD3E18-8D29-42DA-B32C-DD4491951FC0.session: No such file or directory
touch: ~/.bash_sessions/EBDD3E18-8D29-42DA-B32C-DD4491951FC0.historynew: No such file or directory
-bash: history: ~/.bash_sessions/EBDD3E18-8D29-42DA-B32C-DD4491951FC0.historynew: cannot create: No such file or directory

...copying shared history...cp: ~/.bash_sessions/EBDD3E18-8D29-42DA-B32C-DD4491951FC0.history: No such file or directory

...saving history...cat: ~/.bash_sessions/EBDD3E18-8D29-42DA-B32C-DD4491951FC0.historynew: No such file or directory
-bash: ~/.bash_sessions/EBDD3E18-8D29-42DA-B32C-DD4491951FC0.history: No such file or directory
-bash: ~/.bash_sessions/EBDD3E18-8D29-42DA-B32C-DD4491951FC0.historynew: No such file or directory
truncating history files...
...completed.
shlock: open(~/.bash_sessions/shlock6026): No such file or directory

[Process completed]

The other thing is it recreates the .bash_sessions folder if it got removed.

Is this some kind of virus or just that I haven't paid that much attention to it, or is this something that Apple added in El Capitan (I'm running OS X 10.11 Build 15A262E) or what else could it be?

Also when I run login <myusername> then I run exit I do not get this odd output. It only seems to be when closing out of terminal.

Note: I have replaced /Users/myusername with ~/ instead. I have also removed my .bash_profile to make sure it wasn't that.

5 Answers 5

27

This seems to be a change to Bash Session in OS X El Capitan. See Bash sessions

Also see this question in SE.

2
  • 1
    Ah, Thanks for that! Glad to know it is an OS based thing!
    – iProgram
    Commented Sep 20, 2015 at 20:26
  • 13
    Please include all relevant details from pages you’re referring to. They might go away, making your answer incomplete.
    – Daniel B
    Commented Sep 20, 2015 at 20:36
8

had the same problem. Under terminal preferences->profiles -> shell. Select appropriate action to perform under "when the shell exits" menu. Fixed my issue.

1
  • 1
    To just ignore the message and just exit the Terminal, under "When the steel exits:" select "Close if the shell exited cleanly".
    – sharshi
    Commented Feb 23, 2018 at 18:27
0

The last line of /etc/bashrc on the mac reads:

[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"

So to disable all the craziness in the Apple Terminal on exit:

sudo mv /etc/bashrc_Apple_Terminal /etc/bashrc_Apple_Terminal-disabled

0

For me this issue was happening because I was using exit inside of a bash script that I had wrapped/converted into a function. As soon as I replaced exit with return the issue went away.

1
  • This doesn' answer the question.
    – Toto
    Commented Mar 23, 2022 at 16:45
-1

You can add an alias to your shell-profile (like .bashrc) such as:

alias off='exit 0 >/dev/null'

When you use 'off', it exits with those extra messages discarded.

All you get is the 'logout' line, sent to 2>/dev.tty

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .