-
Notifications
You must be signed in to change notification settings - Fork 391
fix: quote boolean command names such as if "$boolean_variable"; then
#914
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eb5630c
fix: quote other boolean variables for custom IFS
akinomyoga 08465a6
refactor(_known_hosts_real): turn `ipv{4,6}` into boolean variables
akinomyoga 9d00d46
refactor(tar): turn `basic_tar` into a boolean variable
akinomyoga a7ef1bf
refactor(make,mutt,strace): use `true` for boolean table
akinomyoga a1db873
refactor(upgradepkg): turn `nofiles` into a boolean variable
akinomyoga 700dd97
refactor(mcrypt,postcat,svcadm,tar,wodim): switch to boolean variables
akinomyoga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ _lzip() | |
return | ||
fi | ||
|
||
if $decompress; then | ||
if "$decompress"; then | ||
_filedir lz | ||
return | ||
fi | ||
|
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 beif [[ "$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 stringset
might as a "set" marker better than1
ortrue
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.
PR #739 and Issue #786 are related. PR #739 contains unrelated long discussions, but the current situation is summarized in the following two comments:
BASH_COMPLETION_FINALIZE_HOOKS
#739 (comment)set -o noglob
in effect #786 (comment)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? 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.
You've got it right. My opinion is still that
if $something; then
reads cleaner thanif [[ $something ]]; then
. But per reasoning here, we can't have the former if we want to protect against funky$IFS
. And I thinkif "$something"; then
with the quotes is so weird that I preferif [[ $something ]]; then
over that.Yes, please. I'd also suggest using literal
set
as the value when the variable is set, instead oftrue
,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.
I reworked them so decided to submit them as another PR #931.