Problem
Multi-line shell commands through exec are nearly impossible due to quote escaping hell. During the Grist migration, every attempt to run more than one command failed silently:
# Broken — quotes inside quotes, \$ escaping, shebangs
h8 kubectl exec pod -- sh -c '
mv /persist/home.sqlite3 /persist/home.sqlite3.bak
tar xzf /persist/backup.tar.gz -C /persist
chown grist:grist /persist/*
'
Ended up having to copy a script file via kubectl cp first, then exec it, then rm it — 3 commands where 1 should work.
Proposal
h8 app exec grist --script '
mv /persist/home.sqlite3 /persist/home.sqlite3.bak
tar xzf /persist/backup.tar.gz -C /persist
chown grist:grist /persist/*
'
Implementation: write the script to a temp file, kubectl cp it to the pod, kubectl exec pod -- sh /tmp/h8-script, then kubectl exec pod -- rm /tmp/h8-script. All transparent to the user.
Stderr from the script should be forwarded, and exit code from the script should be the exit code of the h8 command.
Problem
Multi-line shell commands through
execare nearly impossible due to quote escaping hell. During the Grist migration, every attempt to run more than one command failed silently:Ended up having to copy a script file via
kubectl cpfirst, then exec it, then rm it — 3 commands where 1 should work.Proposal
Implementation: write the script to a temp file,
kubectl cpit to the pod,kubectl exec pod -- sh /tmp/h8-script, thenkubectl exec pod -- rm /tmp/h8-script. All transparent to the user.Stderr from the script should be forwarded, and exit code from the script should be the exit code of the h8 command.