0

When .bashrc is sourced, my terminal immediately closed - I pinpointed it to ~/.bashrc - what's the best way to debug this? Should echo every line to another file? Is there a log I can look to?

It looks like this line is causing the terminal window to close:

ssh-add ~/.ssh/xyz/oresoftware

that file path doesn't exist, so I change it to something that exists:

ssh-add ~/.ssh/oresoftware

but would ssh-add close my terminal window?

  • 1
    Paste the file. – jasonwryan Nov 25 '17 at 04:52
  • looks like it was running ssh-add against a file that didn't exist, but I don't know why that would cause the terminal window to close. I will add the line. – Alexander Mills Nov 25 '17 at 04:54
  • 2
    I assume that you can get to a shell by renaming .bashrc. (1) What does type ssh-add report? (2) Let’s assume that the suspicious ssh-add command is on line 42 of your .bashrc.  Copy lines 1-41 of .bashrc to .bashrc41 and source that.  Does your terminal close?  If it does, the problem occurs before the ssh-add. (3) Otherwise, do type ssh-add again. (4) Then type ssh-add ~/.ssh/xyz/oresoftware.  Now does your terminal close? Then the ssh-add is causing it. (5) If step 4 didn’t kill your terminal, copy lines 1-42 of .bashrc to .bashrc42 and source that. What happens? – G-Man Says 'Reinstate Monica' Nov 25 '17 at 06:29
  • @AlexanderMills What operating system are you using? What terminal application are you using? – igal Nov 25 '17 at 22:04
  • I am on Ubuntu, several different terminals / psuedo-ttys were experiencing the same problem...the native terminal for Ubuntu, as well as the JetBrains terminal emulator. – Alexander Mills Nov 25 '17 at 22:10

1 Answers1

1

I eventually found an answer to this question here: Any command in my terminal that exits with non-zero code closes my terminal window

What was happening is that set -e; was set before the ssh-add call, and ssh-add was exiting with non-zero code, which then caused my terminal window to close.

So ultimately it was a set -e; issue, so thanks @StephenKitt for pointing that out because that helped me. set -e; was in a file which .bashrc was source'ing.