Skip to content

FEATURE: h8 kubectl exec --script for multi-line commands #12

Description

@erfanium

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions