Skip to content

Commit

Permalink
Changed subshell supprt to be opt-in
Browse files Browse the repository at this point in the history
- disabled by default in bash-preexec 0.3.1
  • Loading branch information
rcaloras committed Aug 9, 2016
1 parent 926c545 commit dde817a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 0 additions & 3 deletions bashhub/shell/bashhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ __bh_setup_bashhub() {

# Pull in our libs
source "$BH_DEPS_DIRECTORY/lib-bashhub.sh"

# Disable subshells in bash-preexec
export __bp_disable_subshells="true"
source "$BH_DEPS_DIRECTORY/bash-preexec.sh"

# Hook bashhub into preexec and precmd.
Expand Down
4 changes: 2 additions & 2 deletions bashhub/shell/deps/bash-preexec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ __bp_install() {
# 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
# Disabling this by default. It can be enabled by setting this variable.
if [[ -n "$__bp_enable_subshells" ]]; then

# Set so debug trap will work be invoked in subshells.
set -o functrace > /dev/null 2>&1
Expand Down
2 changes: 1 addition & 1 deletion bashhub/shell/deps/lib-bashhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ __bh_process_command() {
__bh_check_bashhub_installation() {
local ret
ret=0
if [[ -n "$BASH_VERSION" && -z "$__bp_disable_subshells" && "$(trap)" != *"__bp_preexec_invoke_exec"* ]]; then
if [[ -n "$BASH_VERSION" && -n "$__bp_enable_subshells" && "$(trap)" != *"__bp_preexec_invoke_exec"* ]]; then
echo "Bashhub's preexec hook is being overriden and is not saving commands. Please resolve what may be holding the DEBUG trap."
ret=1
elif [[ ! -f "$BH_HOME_DIRECTORY/config" ]]; then
Expand Down
3 changes: 3 additions & 0 deletions tests/shell/lib-bashhub.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ teardown() {

@test "__bh_check_bashhub_installation should find issues and run only once." {

# Enable subshells for these checks to work
export __bp_enable_subshells="true"

# Bash but no trap.
run '__bh_check_bashhub_installation'
[[ $status == 1 ]]
Expand Down

0 comments on commit dde817a

Please sign in to comment.