-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
printf
: support %q
#5472
printf
: support %q
#5472
Conversation
GNU testsuite comparison:
|
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.
That is indeed curious. This does seem to give the same output as ls
. I think echo
might be doing the escaping in your example:
env printf %q '"$test"'
I'd like this to use the same function as in ls
because we have a pretty good robust implementation of it there. The implementation of it is here: https://github.com/uutils/coreutils/blob/main/src/uucore/src/lib/features/quoting_style.rs
Note too that there is a little spelling error (the word "metacharacters" needs to be ignored).
Sorry for the mistake, actually I'm not using the GNU's printf when I directly call
There is an |
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.
Looking good, thanks! Accidentally using the shells printf
happens to me all the time too 😄
@@ -261,7 +261,6 @@ impl SubParser { | |||
} | |||
x if legal_fields.binary_search(&x).is_ok() => { | |||
self.field_char = Some(ch); | |||
self.text_so_far.push(ch); |
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.
This unnecessary push cause wrong error message: printf: %7bb: invalid conversion specification\n
, which has one more b
.
GNU testsuite comparison:
|
4675896
to
51966f5
Compare
fix #5468
Now
printf %q '"$test"'
can produce the right result:However I have a doubt about the description in GNU manual:
And in my local:
What does "equivalent format" mean?