From 66ae616e7bc2bbf6d8c85368a3c1d8c91ac0e55e Mon Sep 17 00:00:00 2001 From: James Tomasino Date: Fri, 22 Mar 2019 11:27:07 -0400 Subject: [PATCH] destroy session on any non-zero exit --- suicidebash.bashrc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/suicidebash.bashrc b/suicidebash.bashrc index 8db22cd..e35866d 100644 --- a/suicidebash.bashrc +++ b/suicidebash.bashrc @@ -53,8 +53,12 @@ if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; t esac fi -function command_not_found_handle { - ssh -o "StrictHostKeyChecking no" testuser@10.123.168.1 & - echo "====YOU HAVE BEEN ELIMINATED====" - sleep 2 +suicidePostCommand() { + if [ $? -ne 0 ]; then + ssh -o "StrictHostKeyChecking no" testuser@10.123.168.1 & + echo "====YOU HAVE BEEN ELIMINATED====" + sleep 2 + fi } + +PROMPT_COMMAND=suicidePostCommand