fix: fix uses of sed/awk scripts#1566
Merged
akinomyoga merged 4 commits intoscop:mainfrom Feb 3, 2026
Merged
Conversation
`$3 = "="` always evaluates to true regardless of whether $3 is actually "=". This results in printing always $2. In this patch, we fix the condition to `$3 == "="`.
In the current implementation, we try to filter out the elements of
"${options[@]}" that already appear in "${words[@]}". The strategy is
to generate
a. "${options[@]}" and
b. the intersect of "${words[@]}" and "${options[@]}"
in a single list and to pick up only unique elements. However, the
current implementation does not correctly generate "b. the intersect".
It also contains elements of words that contain any of "${options[@]}"
as a substring. This possibly results in generating some words in the
command line as options.
scop#1564 (comment)
In this patch, we rather implement the filtering using `_compgen -X`.
The filtering attempted in the iptables completion have not taken effect because `s/.../.../p` (contained in "$chain") has been performed before the filtering by "s/<chains-to-remove>//". In this perspective, the ebtables completion did the correct thing by first performing the filtering and then performing `s/.../.../p`. However, even with the above issue fixed, both the iptables and ebtables completion may wrongly reduce a part of chain names, such as `DOCKER-FORWARD` to `DOCKER-`. The filtering should be done by the exact match. One solution is to split the "sed" invocation into "sed" and "grep -v" and perform the filtering of the exact match in the "grep" command as "grep -vEx 'INPUT|OUTPUT|...'". In this patch, we instead use the option `-X '@(INPUT|OUTPUT|...)'` of `_comp_compgen_split`. scop#1564 (comment) Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
scop
approved these changes
Feb 2, 2026
Owner
scop
left a comment
There was a problem hiding this comment.
LGTM on a quick read, thanks!
GH actions is not feeling great at the moment, good to merge after we get a clean/green CI run, https://www.githubstatus.com/incidents/xwn6hjps36ty
Collaborator
Author
Oh, OK. Thanks for the information. |
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.
These are broken regardless of POSIX.