-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Fix completion #47780
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
[Console] Fix completion #47780
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
7efccdd
to
5ec1459
Compare
Hello @h3xx, thank you for the patch and the details. I worked on this completion script and would like to make some tests. I'm a beginner in bash scripting, but apparently updating https://stackoverflow.com/a/12495480 Did you hit a specific issue? |
Interesting. I didn't know that's what
I'm all in favor of unit tests :-). I'll see what I can come up with, integrating a test for my issue into CI.
Yes, the issue is outlined in the PR's description, but a more concise failure case is thus: On my system, alias ls='/bin/ls $LS_OPTIONS'
LS_OPTIONS="-F -b -T 0 --color=auto --block-size='1"
ls
CHANGELOG-6.0.md CONTRIBUTORS.md UPGRADE-6.1.md phpunit.xml.dist
CHANGELOG-6.1.md LICENSE composer.json psalm.xml
CODE_OF_CONDUCT.md README.md link* src/
CONTRIBUTING.md UPGRADE-6.0.md phpunit* After using this function the alias would no longer work:
|
Changing IFS poisons the shell environment. Use COMP_WORDBREAKS instead.
960f815
to
fa259f5
Compare
Okay, I've added a unit test that successfully reproduces my issue. Now, I'm looking into the |
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.
Thank you very much for working on a test. I tried on a Mac Intel and in Docker Alpine: it fails (see other comments).
The fix actually works and fixes the reported issues. We can keep only the 1st commit and work on tests in a separate PR.
src/Symfony/Component/Console/Tests/Resources/BashCompletionTest.php
Outdated
Show resolved
Hide resolved
$possibles = [ | ||
// Paths to where required shell functions reside | ||
'/etc/bash_completion', | ||
'/usr/share/bash-completion/bash_completion', |
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.
On Mac Intel, none of this files exists. There is /usr/local/Cellar/bash-completion/1.3_3/etc/bash_completion
and /usr/local/Cellar/bash-completion@2/2.11/share/bash-completion/bash_completion
.
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.
On Mac Intel, is bash completion even supported outside of Homebrew?
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.
The real question is, does CI need to run/pass on a Mac? Are any of the CI images used OSX-based?
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, tests must run on all supported environments. They could be skipped if some preconditions are not meet (bash completion not installed).
src/Symfony/Component/Console/Tests/Resources/BashCompletionTest.php
Outdated
Show resolved
Hide resolved
Code review suggestion. Co-authored-by: Jérôme Tamarelle <jerome@tamarelle.net>
What's the status here? |
@nicolas-grekas It's "on my list of things to do." Life is pretty hectic atm. If it lessens your mental load, feel free to close this PR and I will re-open when I get around it. |
No worries, I was just wondering. When you can! |
Closing as there is no more activity. Please feel free to reopen |
Set
COMP_WORDBREAKS
instead ofIFS
in the completion script.More in-depth explanation:
IFS
affects other things not related to programmable completion, such as how the shell breaks up argument lists.For example, by default this splits the unquoted variable as-expected:
Changing IFS makes the variable not split as expected, printing all on one line:
This PR changes it to use
$COMP_WORDBREAKS
which specifically affects how programmable completion works, instead of affecting and effectively poisoning how the user's shell works.