File tree 2 files changed +23
-3
lines changed
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ __bp_precmd_invoke_cmd() {
106
106
# Test existence of functions with: declare -[Ff]
107
107
if type -t " $precmd_function " 1> /dev/null; then
108
108
__bp_set_ret_value " $__bp_last_ret_value " " $__bp_last_argument_prev_command "
109
- $precmd_function
109
+ " $precmd_function "
110
110
fi
111
111
done
112
112
}
@@ -189,7 +189,7 @@ __bp_preexec_invoke_exec() {
189
189
fi
190
190
191
191
local this_command
192
- this_command=$( HISTTIMEFORMAT= builtin history 1 | { read -r _ this_command; echo " $this_command " ; })
192
+ this_command=$( HISTTIMEFORMAT= builtin history 1 | { IFS= " " read -r _ this_command; echo " $this_command " ; })
193
193
194
194
# Sanity check to make sure we have something to invoke our function with.
195
195
if [[ -z " $this_command " ]]; then
@@ -210,7 +210,7 @@ __bp_preexec_invoke_exec() {
210
210
# Test existence of function with: declare -[fF]
211
211
if type -t " $preexec_function " 1> /dev/null; then
212
212
__bp_set_ret_value $__bp_last_ret_value
213
- $preexec_function " $this_command "
213
+ " $preexec_function " " $this_command "
214
214
preexec_function_ret_value=" $? "
215
215
if [[ " $preexec_function_ret_value " != 0 ]]; then
216
216
preexec_ret_value=" $preexec_function_ret_value "
Original file line number Diff line number Diff line change @@ -162,6 +162,26 @@ test_preexec_echo() {
162
162
[[ " ${lines[1]} " == " two" ]]
163
163
}
164
164
165
+ @test " preexec should execute a function with IFS defined to local scope" {
166
+ IFS=_
167
+ name_with_underscores_1 () { parts=(1_2); echo $parts ; }
168
+ preexec_functions+=(name_with_underscores_1)
169
+
170
+ __bp_interactive_mode
171
+ run ' __bp_preexec_invoke_exec'
172
+ [[ $status == 0 ]]
173
+ [[ " $output " == " 1 2" ]]
174
+ }
175
+
176
+ @test " precmd should execute a function with IFS defined to local scope" {
177
+ IFS=_
178
+ name_with_underscores_2 () { parts=(2_2); echo $parts ; }
179
+ precmd_functions+=(name_with_underscores_2)
180
+ run ' __bp_precmd_invoke_cmd'
181
+ [[ $status == 0 ]]
182
+ [[ " $output " == " 2 2" ]]
183
+ }
184
+
165
185
@test " preexec should set \$ ? to be the exit code of preexec_functions" {
166
186
return_nonzero () {
167
187
return 1
You can’t perform that action at this time.
0 commit comments