-
Notifications
You must be signed in to change notification settings - Fork 388
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: quote boolean command names such as if "$boolean_variable"; then
#914
Conversation
71ed5f1
to
938e466
Compare
I decided to separate the change |
if "$boolean_variable"; then
and "$split" && return
)if "$boolean_variable"; then
@@ -806,7 +806,7 @@ _comp_delimited() | |||
fi | |||
[[ $cur == *$delimiter* ]] && prefix=${cur%"$delimiter"*}$delimiter | |||
|
|||
if $deduplicate; then | |||
if "$deduplicate"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. I had written this last week, but forgot to click "Review changes", so the comment was left in pending state. Sorry! Anyway, here goes.
I can't say I'm too enthusiastic about this at least in cases where we are in complete control of the variable's contents.
I can see how this would be necessary to make things work in some crazy $IFS
cases, but I believe the codebase is riddled with things that would break with them (this PR's just scratching the surface), and I'm not convinced we should try and support everything one might want to throw at it. I suppose there was a PR somewhere (which I've likely failed to follow up with) that would ensure a desired environment at start of a completion -- that would sound much preferable over this approach to me.
To me, reading if "$something"; then
raises the question "was this supposed to be if [[ "$something" ]]; then
" (even though the quotes within the square brackets are superfluous) and thus makes the code heavier to read. Also I'm quite convinced that it will take me a long time until I learn to take this into account, and there's no tool to fix it up or warn me. And even if I did learn it, I can't say I'd like it.
I'm leaning towards that we either don't do anything about this at all, or switch to comparing variable values instead of invoking boolean commands they contain, similarly as we did e.g. for the _known_hosts_real
$ipv4
and $ipv6
cases below before this change. I think I'd prefer the string set
might as a "set" marker better than 1
or true
to clearly differentiate from the boolean commands and arithmetic context, but that's a bit besides the point, but in case we're modifying these anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose there was a PR somewhere (which I've likely failed to follow up with) that would ensure a desired environment at start of a completion -- that would sound much preferable over this approach to me.
PR #739 and Issue #786 are related. PR #739 contains unrelated long discussions, but the current situation is summarized in the following two comments:
- feat: implement
BASH_COMPLETION_FINALIZE_HOOKS
#739 (comment) - Aborting a completion attempt leaves
set -o noglob
in effect #786 (comment)
To me, reading
if "$something"; then
raises the question "was this supposed to beif [[ "$something" ]]; then
" (even though the quotes within the square brackets are superfluous) and thus makes the code heavier to read.
I actually prefer [[ $something ]]
with something
being an empty/non-empty variable. The reason that I decided to switch to this direction was item 2 in the review comment #891 (review). Might I have misread the comment? Anyway, if you would like to switch to [[ $something ]]
, I will adjust them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually prefer
[[ $something ]]
withsomething
being an empty/non-empty variable. The reason that I decided to switch to this direction was item 2 in the review comment #891 (review). Might I have misread the comment?
You've got it right. My opinion is still that if $something; then
reads cleaner than if [[ $something ]]; then
. But per reasoning here, we can't have the former if we want to protect against funky $IFS
. And I think if "$something"; then
with the quotes is so weird that I prefer if [[ $something ]]; then
over that.
Anyway, if you would like to switch to
[[ $something ]]
, I will adjust them.
Yes, please. I'd also suggest using literal set
as the value when the variable is set, instead of true
, 1
or the like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please. I'd also suggest using literal
set
as the value when the variable is set, instead oftrue
,1
or the like.
I reworked them so decided to submit them as another PR #931.
The original codes before PR 862, https://github.com/scop/bash-completion/pull/862/files#diff-87387e55a9536f7ac2aa5fce39d9a0442c29ec2058215563388d5a284a9ac1c1L15-R24 were already broken. According to the man page of lzip, lzip supports separate options `--decompress` and `-d`, but there are no options `--decompress-d` or `--decompress-...d`. In this patch, we separate these unexpectedly combined option names. Reference: scop#914 (comment) Co-authored-by: Ville Skyttä <[email protected]>
938e466
to
368dc46
Compare
The original codes before PR 862, https://github.com/scop/bash-completion/pull/862/files#diff-87387e55a9536f7ac2aa5fce39d9a0442c29ec2058215563388d5a284a9ac1c1L15-R24 were already broken. According to the man page of lzip, lzip supports separate options `--decompress` and `-d`, but there are no options `--decompress-d` or `--decompress-...d`. In this patch, we separate these unexpectedly combined option names. Reference: scop#914 (comment) Co-authored-by: Ville Skyttä <[email protected]>
368dc46
to
df3f04b
Compare
The original codes before PR 862, https://github.com/scop/bash-completion/pull/862/files#diff-87387e55a9536f7ac2aa5fce39d9a0442c29ec2058215563388d5a284a9ac1c1L15-R24 were already broken. According to the man page of lzip, lzip supports separate options `--decompress` and `-d`, but there are no options `--decompress-d` or `--decompress-...d`. In this patch, we separate these unexpectedly combined option names. Reference: #914 (comment) Co-authored-by: Ville Skyttä <[email protected]>
df3f04b
to
d38a20c
Compare
d38a20c
to
700dd97
Compare
|
I have created this branch after #891 (comment) but left it for about one month. Now there was a related discussion in #910 (comment), so I decided to submit it here.
edit: This branch also includes other fixes: 7b6fb48, e731fc4, 7971f50