Skip to content

connect: '-- bash -lc "<cmd>"' mangles multi-token commands (argv re-split) #369

Closed

Description

@scttfrdmn

Version: spawn 0.77.0

Summary: spawn connect <id> -- bash -lc "<command string>" does not deliver the command string as a single argument to bash -lc. When the command contains spaces (i.e. any real command), the remote side fails with:

bash: -c: option requires an argument

Repro:

# fails — the string after -lc is re-split, so -c gets an empty/partial arg
spawn connect my-instance -- bash -lc "echo hello && echo world"
# → bash: -c: option requires an argument

Expected: the quoted command runs as one script, printing hello\nworld.

Impact: any non-trivial remote command via connect -- bash -lc (pipes, &&, quotes) is unusable. This bites automation that drives instances programmatically (e.g. aws ecr get-login-password | docker login ... && docker pull ...).

Workaround that works: feed the script over stdin instead of argv —

printf '%s\n' 'echo hello && echo world' | spawn connect my-instance -- bash -s

This reliably preserves the payload, which suggests connect's handling of the post--- argv (or how it assembles the remote SSH command) is re-splitting/again-parsing the arguments rather than passing them through verbatim.

Ask: pass the post--- argument vector to the remote shell without re-splitting (e.g. exec-style / properly quoted), so -- bash -lc '<one arg>' behaves as it does over plain ssh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions