-
Notifications
You must be signed in to change notification settings - Fork 184
perl-for-cntrl-chars #34
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
Conversation
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.
Hi, @joesuf4 sorry for late answer. I'm going to review your PR
kubectl-node_shell
Outdated
@@ -75,7 +75,7 @@ done | |||
if [ $# -gt 0 ]; then | |||
while [ $# -gt 0 ]; do | |||
cmd="$cmd, \"$(echo "$1" | \ | |||
awk '{gsub(/\\/,"\\\\");gsub(/"/,"\\\"");gsub(/$/,"\\n");printf last}{last=$0} END{gsub(/\\n/,"",last);printf last}' \ | |||
perl -pl -0777 -e 's/([\\"])/\\$1/g;s/\n$//;s/\n/\\n/g;s/([\x01-\x1f])/sprintf "\\u%04x",ord $1/ge' \ |
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.
Unfortunately perl
is not installed on many systems by default, let's try using as less dependencies as we can.
Awk was a nice solution, and persist almost everywhere, so why not using it?
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.
Because it doesn't handle control-characters like 0x1b, which I need? https://datatracker.ietf.org/doc/html/rfc7159#section-7
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.
Exactly which systems have kubectl installed, but not perl? Windows?
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.
Many of them, even linux distros: for example centos, alpine linux, archlinux have no it out of box.
4a51f3a
to
3ae2b92
Compare
If you want to implement most of the JSON spec faithfully, as it relates to the bulk of 7-bit ascii, you need to use something with more power than awk. If you just want to support my use case, and stick to awk, that's also fine with me. This MR has that developed in the final commit. |
This become to be a madness. I committed please rebase your PR and run |
All tests pass. Should be good to go now. Thanks for the test suite! |
@joesuf4 thanks! Could you also add the test case you solving by this change? |
Done. |
Perfect, thank you for contribution! |
No description provided.