-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting IFS=_
breaks __bp_precmd_invoke_cmd
#64
Comments
- Fix for #64 - bash-preexec would break if IFS was changed. It should be default for the way we're using arrays and read.
- Fix for #64 - bash-preexec would break if IFS was changed. It should be default for the way we're using arrays and read.
@gnachman Thanks for reporting! Did as you suggested storing it. I created a couple small helpers based on https://unix.stackexchange.com/a/264947. Give #65 a quick look when you get a sec. I'll cut a version as soon as it's merged. |
cc @d630 @dimo414 @lguelorget bash-preexec's ⭐️ contributors. |
I worry the proposed fix would essentially introduce the opposite problem, since the user's function would be invoked with bash-preexec's What exactly is the behavior that's IFS-dependent currently? At a glance I don't see it. |
- Fix for #64 - bash-preexec would break if IFS was changed. It should be default for the way we're using arrays and read.
Updated to set original IFS across |
Can you share a particular example? I believe that array-splitting (e.g. |
Ja, I don't think setting/resetting of IFS is necessary. But you have to take care about (at least):
# stupid
printf -v n %\*s 125 ' ';
this_command=$(HISTTIMEFORMAT=$'\r'$n$'\r' builtin history 1);
alias __bp_set_ret_value=ls;
__bp_set_ret_value; So, I suggest: if type -t "$precmd_function" 1>/dev/null; then
\__bp_set_ret_value "$__bp_last_ret_value" "$__bp_last_argument_prev_command"
"$precmd_function"
fi One can even think about turning on the readonly attribute ... |
Ok sorry, I just realized the issue is specifically with I think the right first step is to add some unit tests that everything works as expected with a malicious IFS. Capturing and restoring the IFS may be the best option. We might be able to avoid it (e.g. by more aggressively quoting everything in bash-preexec), but that may be more trouble than it's worth. |
- Fixes bug where IFS in outer environment could be set to something that would cause our inner functions to break on varibale expansion. - Added a couple unit tests.
I received the following issue report:
https://gitlab.com/gnachman/iterm2/issues/6398
The internals of
__bp_precmd_invoke_cmd
assumeIFS
has its default value. I think you could do this:__bp_precmd_invoke_cmd
, save the current value ofIFS
to a local variableIFS
to\t\n
__bp_precmd_invoke_cmd
restoreIFS
to the saved value.What do you think?
The text was updated successfully, but these errors were encountered: