-
Notifications
You must be signed in to change notification settings - Fork 379
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 the printf unescaping in "_quote_readline_by_ref" #526
Fix the printf unescaping in "_quote_readline_by_ref" #526
Conversation
ab58390
to
63f944f
Compare
Cool, thanks. This is pretty intricate stuff, frankly much more low level than I'm comfortable with, but not at all your fault and seems necessary here. Added some lint fixes (highly recommended to install pre-commit, added a blurb about that in e1c400a). I guess the only bit of an issue I'd like to see addressed is that the rendered cmd appears to assume PS1 length of 2, seems kind of magical. Maybe add some comment clarifying that, or even define it in terms of PS1 length, e.g. rendered_cmd="echo alpha\\"
rendered_cmd += " " * (8 - (len(conftest.PS1 + rendered_cmd) % 8)) + "b" ...but that's not too clear either, maybe a comment would do better. |
Thank you for the instruction! I have installed $ pre-commit run --from-ref @~ --to-ref @ -v --show-diff-on-failure --all-files Is there any other correct (shorter) command to perform the lint check on the previous commit? Or do I need to run this long command every time? Anyway, some lint errors have been automatically corrected and reflected in the actual files. But there are still errors by
If I directly run
Anyway, I push the commit of the current status e4ef29e.
Yes.
I added a comment in |
But very nice, thanks a bunch again! |
Ah, OK. I see. Thank you! |
This is the PR for the fix discussed in the conversation #492 (comment). We want to revert the following change:
I have included the tests along with the fix.
conftest.py (52814dd): add an optional argument
rendered_cmd
Because I need to make a test that involves a TAB character in the filenames, I would like to add this new argument to support command lines in which the actual input sequence and the result rendered to the terminal are different. For example, suppose we think about a command-line string
"echo alpha\\\tb"
:"echo alpha\\\026\tb"
i.e., e c h o SP a l p h a \ C-v TAB b"echo alpha\\\tb"
i.e., e c h o SP a l p h a \ TAB b"/@echo alpha\\ b"
i.e. / @ e c h o SP a l p h a \ SP SP SP b where/@
is the prompt.The current problem of the testing framework is that it assumes that
A == C
and just performsbash.expect_exact
for the input string A. In this commit, I allow users to optionally specify C through the named argumentrendered_cmd="..."
. As I'm not a native English speaker, I don't have a good sense of choosing the argument name. If you have a better idea for the name of the new argument, could you please specify it?unit/test_quote_readline.py (608badf): add a failing test
This tests the completion results for
"echo alpha\\\tb"
.bash_completion (ab58390): fix
_quote_readline_by_ref
This is the suggested change of removing
%s
fromprintf
.