-
Notifications
You must be signed in to change notification settings - Fork 184
old-bash-support #32
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
old-bash-support #32
Conversation
8f0c35d
to
7c3a9b1
Compare
@joesuf4, thanks for your PR! ./kubectl-node_shell $node -- sh -c "
echo \"ggg\"" debug output+ set -e + kubectl=kubectl + generator= + node= + nodefaultctx=0 + nodefaultns=0 + cmd=(nsenter --target 1 --mount --uts --ipc --net --pid --) + custom=false + '[' -t 0 ']' + tty=true + '[' 5 -gt 0 ']' + key=m1c4 + case $key in + '[' -z '' ']' + node=m1c4 + shift + '[' 4 -gt 0 ']' + key=-- + case $key in + shift + break + '[' 0 = 1 ']' ++ kubectl config current-context + kubectl='kubectl --context=stage-opennebula' + '[' 0 = 1 ']' ++ kubectl --context=stage-opennebula config view --minify --output 'jsonpath={.contexts..namespace}' + kubectl='kubectl --context=stage-opennebula --namespace=opennebula' + '[' 3 -gt 0 ']' + cmd+=("${@// /\\n}") + cmd=("${cmd[@]//\'/\"}") ++ echo -e '['\''nsenter'\'', '\''' '--target'\'', '\''' '1'\'', '\''' '--mount'\'', '\''' '--uts'\'', '\''' '--ipc'\'', '\''' '--net'\'', '\''' '--pid'\'', '\''' '--'\'', '\''' 'sh'\'', '\''' '-c'\'', '\''' '\n\necho "ggg"'\'', '\'''\'']' ++ sed -e 's/'\'' /'\''/g' -e 's/, '\'''\'']$/]/' -Ee 's/(["\\])/\\\1/g' -e 's/\\\\n/\\n/g' ++ tr \' '"' + entrypoint='["nsenter", "--target", "1", "--mount", "--uts", "--ipc", "--net", "--pid", "--", "sh", "-c", "
echo "ggg""]
echo "ggg""]
version information$ bash --version GNU bash, version 5.1.8(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later |
baa7c5f
to
8fc5e1e
Compare
Try again with latest patch.
On Wed, Jul 7, 2021 at 9:43 AM Andrei Kvapil ***@***.***> wrote:
@joesuf4 <https://github.com/joesuf4>, thanks for your PR!
The flowing command is not working to me:
./kubectl-node_shell $node -- sh -c "echo \"ggg\""
debug output
+ set -e
+ kubectl=kubectl
+ generator=
+ node=
+ nodefaultctx=0
+ nodefaultns=0
+ cmd=(nsenter --target 1 --mount --uts --ipc --net --pid --)
+ custom=false
+ '[' -t 0 ']'
+ tty=true
+ '[' 5 -gt 0 ']'
+ key=m1c4
+ case $key in
+ '[' -z '' ']'
+ node=m1c4
+ shift
+ '[' 4 -gt 0 ']'
+ key=--
+ case $key in
+ shift
+ break
+ '[' 0 = 1 ']'
++ kubectl config current-context
+ kubectl='kubectl --context=stage-opennebula'
+ '[' 0 = 1 ']'
++ kubectl --context=stage-opennebula config view --minify --output 'jsonpath={.contexts..namespace}'
+ kubectl='kubectl --context=stage-opennebula --namespace=opennebula'
+ '[' 3 -gt 0 ']'
+ cmd+=("${@//
/\\n}")
+ cmd=("${cmd[@]//\'/\"}")
++ echo -e '['\''nsenter'\'', '\''' '--target'\'', '\''' '1'\'', '\''' '--mount'\'', '\''' '--uts'\'', '\''' '--ipc'\'', '\''' '--net'\'', '\''' '--pid'\'', '\''' '--'\'', '\''' 'sh'\'', '\''' '-c'\'', '\''' '\n\necho "ggg"'\'', '\'''\'']'
++ sed -e 's/'\'' /'\''/g' -e 's/, '\'''\'']$/]/' -Ee 's/(["\\])/\\\1/g' -e 's/\\\\n/\\n/g'
++ tr \' '"'
+ entrypoint='["nsenter", "--target", "1", "--mount", "--uts", "--ipc", "--net", "--pid", "--", "sh", "-c", "
echo "ggg""]'
- '[' -z m1c4 ']'
- image=docker.io/library/alpine
++ env LC_ALL=C tr -dc a-z0-9
++ head -c 6
- pod=nsenter-4n8vr2
- kubectl --context=stage-opennebula --namespace=opennebula get node m1c4
++ cat
- overrides='{
"spec": {
"nodeName": "m1c4",
"hostPID": true,
"hostNetwork": true,
"containers": [
{
"securityContext": {
"privileged": true
},
"image": "docker.io/library/alpine",
"name": "nsenter",
"stdin": true,
"stdinOnce": true,
"tty": true,
"command": ["nsenter", "--target", "1", "--mount", "--uts", "--ipc", "--net", "--pid", "--", "sh", "-c", "
echo "ggg""]
}
],
"tolerations": [
{
"key": "CriticalAddonsOnly",
"operator": "Exists"
},
{
"effect": "NoExecute",
"operator": "Exists"
}
]
}
}'
++ kubectl version --client -o yaml
++ awk '-F[ :"]+' '$2 == "minor" {print $3+0}'
- m=21
- '[' 21 -lt 18 ']'
- trap 'EC=$?; kubectl --context=stage-opennebula --namespace=opennebula delete pod --wait=false nsenter-4n8vr2 >&2 || true; exit $EC' EXIT INT TERM
- echo 'spawning "nsenter-4n8vr2" on "m1c4"'
spawning "nsenter-4n8vr2" on "m1c4"
++ '[' -t 0 ']'
++ echo -t
- kubectl --context=stage-opennebula --namespace=opennebula run --image docker.io/library/alpine --restart=Never '--overrides={
"spec": {
"nodeName": "m1c4",
"hostPID": true,
"hostNetwork": true,
"containers": [
{
"securityContext": {
"privileged": true
},
"image": "docker.io/library/alpine",
"name": "nsenter",
"stdin": true,
"stdinOnce": true,
"tty": true,
"command": ["nsenter", "--target", "1", "--mount", "--uts", "--ipc", "--net", "--pid", "--", "sh", "-c", "
echo "ggg""]
}
],
"tolerations": [
{
"key": "CriticalAddonsOnly",
"operator": "Exists"
},
{
"effect": "NoExecute",
"operator": "Exists"
}
]
}
}' -t -i nsenter-4n8vr2
error: Invalid JSON Patch
- EC=1
- kubectl --context=stage-opennebula --namespace=opennebula delete pod --wait=false nsenter-4n8vr2
Error from server (NotFound): pods "nsenter-4n8vr2" not found
- true
- exit 1
versions
$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ sed --version
sed (GNU sed) 4.8
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
Paolo Bonzini, Jim Meyering, and Assaf Gordon.
This sed program was built without SELinux support.
GNU sed home page: https://www.gnu.org/software/sed/.
General help using GNU software: https://www.gnu.org/gethelp/.
E-mail bug reports to: ***@***.***
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFEPDUROX2MLNLOCHKAMNDTWRKY5ANCNFSM475XPVMQ>
.
--
Joe Schaefer, Ph.D.
***@***.***>
954.253.3732 <//954.253.3732>
|
9ad6c11
to
0289bb8
Compare
- echo -e - requires more newline escapes
Okay, here is also a few amount of tests: ./kubectl-node_shell $node -- sh -c 'echo $(echo "
hello everybody
I'\''m a \"baby seal\""
)'
./kubectl-node_shell $node -- sh -c "
echo \"ggg
ttt\""
./kubectl-node_shell $node -- sh -c 'echo $(echo "
hello everybody
I'\''m a \"baby seal
really really
\""
)' |
Actually I wrote these tests for myself you can still implement them. Although I still not sure about the advantages of sed+bash over pure shell+awk version. Awk and bourne shell is the same almost everywhere. Thus if you can't convince me, I'm going to merge version from #31 |
Thanks for the tip! I say follow you bliss and release the awk version.
The point is the simplicity and portability, and I think you have it
covered now to support my use cases.
…On Thu, Jul 8, 2021 at 1:44 PM Andrei Kvapil ***@***.***> wrote:
Actually I wrote these tests for myself you can still implement them.
Although I still not sure about the advantages of sed+bash over pure
shell+awk version. Awk and bourne shell is the same almost everywhere. Thus
if you can't convince me, I'm going to merge version from #31
<#31>
FYI
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFEPDVO346CSGEEVHOWELDTWXPXTANCNFSM475XPVMQ>
.
--
Joe Schaefer, Ph.D.
***@***.***>
954.253.3732 <//954.253.3732>
|
To be clear, the problem with the portability is because of a bug in bash
v4. It doesn't correctly handle backslash escaped quotes correctly in a
variable substitution (target) string. Fixed in v5.
…On Thu, Jul 8, 2021 at 2:38 PM Joe Schaefer ***@***.***> wrote:
Thanks for the tip! I say follow you bliss and release the awk version.
The point is the simplicity and portability, and I think you have it
covered now to support my use cases.
On Thu, Jul 8, 2021 at 1:44 PM Andrei Kvapil ***@***.***>
wrote:
> Actually I wrote these tests for myself you can still implement them.
> Although I still not sure about the advantages of sed+bash over pure
> shell+awk version. Awk and bourne shell is the same almost everywhere. Thus
> if you can't convince me, I'm going to merge version from #31
> <#31>
> FYI
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#32 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAFEPDVO346CSGEEVHOWELDTWXPXTANCNFSM475XPVMQ>
> .
>
--
Joe Schaefer, Ph.D.
***@***.***>
954.253.3732 <//954.253.3732>
--
Joe Schaefer, Ph.D.
***@***.***>
954.253.3732 <//954.253.3732>
|
Here, it meant this expression "'${cmd[@]/%/\', \'}'" is a mess without
echo -e. No worries, glad to see awk deal cleanly.
…On Thu, Jul 8, 2021 at 2:43 PM Joe Schaefer ***@***.***> wrote:
To be clear, the problem with the portability is because of a bug in bash
v4. It doesn't correctly handle backslash escaped quotes correctly in a
variable substitution (target) string. Fixed in v5.
On Thu, Jul 8, 2021 at 2:38 PM Joe Schaefer ***@***.***> wrote:
> Thanks for the tip! I say follow you bliss and release the awk version.
> The point is the simplicity and portability, and I think you have it
> covered now to support my use cases.
>
> On Thu, Jul 8, 2021 at 1:44 PM Andrei Kvapil ***@***.***>
> wrote:
>
>> Actually I wrote these tests for myself you can still implement them.
>> Although I still not sure about the advantages of sed+bash over pure
>> shell+awk version. Awk and bourne shell is the same almost everywhere. Thus
>> if you can't convince me, I'm going to merge version from #31
>> <#31>
>> FYI
>>
>> —
>> You are receiving this because you were mentioned.
>> Reply to this email directly, view it on GitHub
>> <#32 (comment)>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/AAFEPDVO346CSGEEVHOWELDTWXPXTANCNFSM475XPVMQ>
>> .
>>
>
>
> --
> Joe Schaefer, Ph.D.
> ***@***.***>
> 954.253.3732 <//954.253.3732>
>
>
>
--
Joe Schaefer, Ph.D.
***@***.***>
954.253.3732 <//954.253.3732>
--
Joe Schaefer, Ph.D.
***@***.***>
954.253.3732 <//954.253.3732>
|
fixes #29