Skip to content

Commit 3458480

Browse files
committed
Remove ignorespace from $HISTCONTROL
- Brought up in issue rcaloras#6
1 parent a3327c3 commit 3458480

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

bash-preexec.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ if [[ "$__bp_imported" == "defined" ]]; then
4040
fi
4141
__bp_imported="defined"
4242

43+
44+
# Remove ignorespace from HISTCONTROL so we can accurately
45+
# invoke preexec with a command from our history even if it
46+
# starts with a space.
47+
export HISTCONTROL="${HISTCONTROL//ignorespace}"
48+
49+
4350
# This variable describes whether we are currently in "interactive mode";
4451
# i.e. whether this shell has just executed a prompt and is waiting for user
4552
# input. It documents whether the current command invoked by the trace hook is

test/bash-preexec.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,10 @@ test_preexec_echo() {
113113
[[ $status == 1 ]]
114114

115115
}
116+
117+
@test "HISTCONTROL should remove ignorespace" {
118+
119+
HISTCONTROL="ignorespace:ignoredups:*"
120+
HISTCONTROL="${HISTCONTROL//ignorespace}"
121+
[[ "$HISTCONTROL" == ":ignoredups:*" ]]
122+
}

0 commit comments

Comments
 (0)