Skip to content

Commit

Permalink
BUGFIX: Was breaking on systems where PROMPT_COMMAND has an existing …
Browse files Browse the repository at this point in the history
…arg.

- Have to set interactive mode 'on', as the last thing in PROMPT_COMMAND.
  • Loading branch information
rcaloras committed Feb 25, 2015
1 parent 3ea73b1 commit d991873
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bash-preexec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ __bp_trim_whitespace() {
echo -n "$var"
}

# This function is installed as the PROMPT_COMMAND; it is invoked before each
# interactive prompt display. It sets a variable to indicate that the prompt
# was just displayed, to allow the DEBUG trap to know that the next
# command is likely interactive.
#
# This function is installed as part of the PROMPT_COMMAND;
# It sets a variable to indicate that the prompt was just displayed,
# to allow the DEBUG trap to know that the next command is likely interactive.
__bp_interactive_mode() {
__bp_preexec_interactive_mode="on";
}


# This function is installed as part of the PROMPT_COMMAND.
# It will invoke any functions defined in the precmd_functions array.
__bp_precmd_invoke_cmd() {

Expand All @@ -75,7 +79,6 @@ __bp_precmd_invoke_cmd() {
$precmd_function
fi
done
__bp_preexec_interactive_mode="on";
}

# Sets a return value in $?. We may want to get access to the $? variable in our
Expand Down Expand Up @@ -189,7 +192,7 @@ __bp_preexec_and_precmd_install() {
fi

# Finally install our traps.
PROMPT_COMMAND="__bp_precmd_invoke_cmd; ${existing_prompt_command}"
PROMPT_COMMAND="__bp_precmd_invoke_cmd; ${existing_prompt_command} __bp_interactive_mode;"
trap '__bp_preexec_invoke_exec' DEBUG;

# Add two functions to our arrays for convenience
Expand Down

0 comments on commit d991873

Please sign in to comment.