Repository navigation
feat(api): expand_shell_words — the shell-expand-line expansion tail - #2426
Merged
Merged
Conversation
GNU shell_expand_line (bashline.c:2982) runs alias_expand, then
expand_word over the whole line, then string_list. expand_word
performs word splitting (subst.c word_list_split) but never filename
globbing ("globbing is *NOT* done for word or string expansion").
Add Session::expand_shell_words for the niubash M-C-e host widget
(niubash#767): quote-aware word split, engine expansion per word, IFS
field split for unquoted results, single-space rejoin. Pinned against
the bash 5.3.20 oracle: unquoted `a b` -> `a b`, quoted stays
`a b` with quotes removed, `*` stays literal, `$'x\ty'` stays one
field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
Session::expand_shell_words, the engine face the niubashM-C-ehost widget (niubash#767) needs after its history/alias legs.GNU
shell_expand_line(bashline.c:2982) runsalias_expand, thenexpand_wordover the whole line, thenstring_list.expand_wordperforms word splitting (subst.cword_list_split) but never filename globbing — subst.c is explicit: "filename globbing is NOT done for word or string expansion, just when the shell is expanding a command."The new entry:
expand_word,Pinned against the bash 5.3.20 oracle (M-C-e then C-x C-e to dump the readline buffer):
VAR='a b'; echo $VAR→echo a bVAR='a b'; echo "$VAR"→echo a b(quotes removed, spacing kept)echo *→echo *echo $'x\ty'→ one field with the tabSix unit tests added (
expand_shell_words_tests).The companion niubash change consumes this API; it should merge after this PR.