From d76f3d236914073057cb9b3c8e9bfde169d030c8 Mon Sep 17 00:00:00 2001 From: Ryan Caloras Date: Sun, 24 Jul 2016 20:16:23 -0400 Subject: [PATCH] Add option to disable subshells to help with #25 --- bash-preexec.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bash-preexec.sh b/bash-preexec.sh index 31aa937..13db194 100644 --- a/bash-preexec.sh +++ b/bash-preexec.sh @@ -11,7 +11,7 @@ # Author: Ryan Caloras (ryan@bashhub.com) # Forked from Original Author: Glyph Lefkowitz # -# V0.3.0 +# V0.3.1 # # General Usage: @@ -234,9 +234,17 @@ __bp_install() { # Adjust our HISTCONTROL Variable if needed. __bp_adjust_histcontrol - # Set so debug trap will work be invoked in subshells. - set -o functrace > /dev/null 2>&1 - shopt -s extdebug > /dev/null 2>&1 + + # Issue #25. Setting debug trap for subshells causes sessions to exit for + # backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash. + # + # This option allows you to disable subshells. + if [[ -z "$__bp_disable_subshells" ]]; then + + # Set so debug trap will work be invoked in subshells. + set -o functrace > /dev/null 2>&1 + shopt -s extdebug > /dev/null 2>&1 + fi; local existing_prompt_command