Skip to content
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

fix(bash): work around custom IFS #1514

Merged
merged 1 commit into from Jan 7, 2024
Merged

Conversation

akinomyoga
Copy link
Contributor

When the user sets a custom value of IFS, the up keybinding may fail because the option --shell-up-key-binding passed to __atuin_history is broken by the word splitting of the shell. For example, when the user sets IFS=-, atuin called from __atuin_history receives shell up key binding <content> as the search string.

$ IFS=-
$ echo [up] # <-- this does not work as expected

Note that the problem only happens with the plain Bash without ble.sh. The problem does not arise within ble.sh because ble.sh separates the user environment and the line-editor environment by saving/restoring the shell settings. The keybindings are processed in the line-editor environment in ble.sh, so the custom IFS set by the user does not affect it.

In this patch, we properly quote the arguments to the atuin command.

When the user sets a custom value of IFS, the up keybinding may fail
because the option `--shell-up-key-binding` passed to
`__atuin_history` is broken by the word splitting of the shell.  For
example, when the user sets IFS=-, `atuin` called from __atuin_history
receives `shell up key binding <content>` as the search string.

$ IFS=-
$ echo [up] # <-- this does not work as expected

Note that the problem only happens with the plain Bash without ble.sh.
The problem does not arise within ble.sh because ble.sh separates the
user environment and the line-editor environment by saving/restoring
the shell settings.  The keybindings are processed in the line-editor
environment, so the custom IFS set by the user does not affect it.

In this patch, we properly quote the arguments to the atuin command.
Copy link

vercel bot commented Jan 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
atuin-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2024 1:28am

Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@ellie ellie enabled auto-merge (squash) January 7, 2024 16:37
@ellie ellie merged commit 31c6ec0 into atuinsh:main Jan 7, 2024
10 checks passed
@akinomyoga akinomyoga deleted the bash-IFS branch January 7, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants