zed-industries/zed · error

shell quoting

Error message

shell quoting

What it means

ssh_command hit an error while shell-quoting the remote command. Because SSH re-splits remote arguments, commands must be quoted (e.g. "cd; sh -c 'ls -l /tmp'"); a quoting failure means an argument could not be safely escaped for the target shell.

Source

Thrown at crates/remote/src/transport/ssh.rs:1358

    // :WARNING: ssh unquotes arguments when executing on the remote :WARNING:
    // e.g. $ ssh host sh -c 'ls -l' is equivalent to $ ssh host sh -c ls -l
    // and passes -l as an argument to sh, not to ls.
    // Furthermore, some setups (e.g. Coder) will change directory when SSH'ing
    // into a machine. You must use `cd` to get back to $HOME.
    // You need to do it like this: $ ssh host "cd; sh -c 'ls -l /tmp'"
    fn ssh_command(
        &self,
        shell_kind: ShellKind,
        program: &str,
        args: &[impl AsRef<str>],
        allow_pseudo_tty: bool,
    ) -> util::command::Command {
        let mut command = util::command::new_command("ssh");
        let program = shell_kind.prepend_command_prefix(program);
        let mut to_run = shell_kind
            .try_quote_prefix_aware(&program)
            .expect("shell quoting")
            .into_owned();
        for arg in args {
            // We're trying to work with: sh, bash, zsh, fish, tcsh, ...?
            debug_assert!(
                !arg.as_ref().contains('\n'),
                "multiline arguments do not work in all shells"
            );
            to_run.push(' ');
            to_run.push_str(&shell_kind.try_quote(arg.as_ref()).expect("shell quoting"));
        }
        let to_run = if shell_kind == ShellKind::Cmd {
            to_run // 'cd' prints the current directory in CMD
        } else {
            let separator = shell_kind.sequential_commands_separator();
            format!("cd{separator} {to_run}")
        };
        self.ssh_options(&mut command, true, None)
            .arg(self.connection_options.ssh_destination());

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure args contain no unquotable control characters; reject or sanitize them first
  2. Use shell_kind to select the correct quoting rules for the remote shell
  3. Include the offending argument in the error message for diagnosis
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/remote/src/transport/ssh.rs:1358 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/3d92427d4ba94d78. Report an issue: GitHub.