-
Notifications
You must be signed in to change notification settings - Fork 30k
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
doc: confusing language in util.format() docs #12362
Comments
This works correctly in node 0.12 |
to me, if |
FWIW it's only an issue when you don't pass any additional arguments to |
The current behaviour also matches the one that browsers have in @evanlucas The idea is been that if strings like |
(https://nodejs.org/dist/latest-v7.x/docs/api/util.html#util_util_format_format_args) I'd rather we clarify it here that if a string is the only argument, it cannot be a format string by definition, so it is returned as is. |
@addaleax I probably should have clarified. I was thinking only in the case of a single argument. |
Yeah, I realized too late that I probably misunderstood you. 😄 |
So how about making it a good first contribution documentation issue (#12362 (comment))? |
I still think, that util.format should behave more like printf in C than console.log in javascript. |
The case is winston logging a sql query with wildcards Given that there wasn't a testcase allowing the performance improvement to break code unnoticed, I'd still opt for printf behavior over console.log. |
#include <stdio.h>
int main() {
printf("%%\n");
} will print |
What printf() does is irrelevant though, util.format() is used to implement console.log() and that prints '%%' in browsers and node. Moving to close. |
@bnoordhuis the docs mention printf specifically... So it is definitely not irrelevant. Furthermore, the bug was unintentionally introduced in given commit. There should have been a testcase. This is just wrong! |
I'm willing to concede the docs are wrong (didn't check) but the behavior itself brings node closer to browsers. I see no reason to roll that back. "It's not like printf" is not a compelling argument to me. |
I guess this is a docs issue? |
Yeah, definitely a docs issue IMO. I think the current behavior is correct given that |
Hey, I'd like to help with this! 🙋 |
@tarunbatra great, go for it! You can ping me here, in #node-dev on Freenode or via direct messages on Twitter (username is the same) if you need any help. I'd say Open a PR though, and reviewers will help find the best wording :) |
Set the expected outcome of `util.format('%%')` to be `%%` instead of `%`. PR-URL: #12374 Fixes: #12362 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Set the expected outcome of `util.format('%%')` to be `%%` instead of `%`. PR-URL: #12374 Fixes: #12362 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Set the expected outcome of `util.format('%%')` to be `%%` instead of `%`. PR-URL: #12374 Fixes: #12362 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Set the expected outcome of `util.format('%%')` to be `%%` instead of `%`. PR-URL: #12374 Fixes: #12362 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Set the expected outcome of `util.format('%%')` to be `%%` instead of `%`. PR-URL: #12374 Fixes: #12362 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Set the expected outcome of `util.format('%%')` to be `%%` instead of `%`. PR-URL: nodejs/node#12374 Fixes: nodejs/node#12362 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
214d020
The intention to speed up util.format breaks the following case:
prior to this commit, this returned '%', now it returns '%%'.
Imho, this is a bug and should be reverted.
The text was updated successfully, but these errors were encountered: