{"record":{"id":"3d92427d4ba94d78","repo":"zed-industries/zed","slug":"shell-quoting","errorCode":null,"errorMessage":"shell quoting","messagePattern":"shell quoting","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/remote/src/transport/ssh.rs","lineNumber":1358,"sourceCode":"\n    // :WARNING: ssh unquotes arguments when executing on the remote :WARNING:\n    // e.g. $ ssh host sh -c 'ls -l' is equivalent to $ ssh host sh -c ls -l\n    // and passes -l as an argument to sh, not to ls.\n    // Furthermore, some setups (e.g. Coder) will change directory when SSH'ing\n    // into a machine. You must use `cd` to get back to $HOME.\n    // You need to do it like this: $ ssh host \"cd; sh -c 'ls -l /tmp'\"\n    fn ssh_command(\n        &self,\n        shell_kind: ShellKind,\n        program: &str,\n        args: &[impl AsRef<str>],\n        allow_pseudo_tty: bool,\n    ) -> util::command::Command {\n        let mut command = util::command::new_command(\"ssh\");\n        let program = shell_kind.prepend_command_prefix(program);\n        let mut to_run = shell_kind\n            .try_quote_prefix_aware(&program)\n            .expect(\"shell quoting\")\n            .into_owned();\n        for arg in args {\n            // We're trying to work with: sh, bash, zsh, fish, tcsh, ...?\n            debug_assert!(\n                !arg.as_ref().contains('\\n'),\n                \"multiline arguments do not work in all shells\"\n            );\n            to_run.push(' ');\n            to_run.push_str(&shell_kind.try_quote(arg.as_ref()).expect(\"shell quoting\"));\n        }\n        let to_run = if shell_kind == ShellKind::Cmd {\n            to_run // 'cd' prints the current directory in CMD\n        } else {\n            let separator = shell_kind.sequential_commands_separator();\n            format!(\"cd{separator} {to_run}\")\n        };\n        self.ssh_options(&mut command, true, None)\n            .arg(self.connection_options.ssh_destination());","sourceCodeStart":1340,"sourceCodeEnd":1376,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/remote/src/transport/ssh.rs#L1340-L1376","documentation":"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.","triggerScenarios":"Thrown at crates/remote/src/transport/ssh.rs:1358 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure args contain no unquotable control characters; reject or sanitize them first","Use shell_kind to select the correct quoting rules for the remote shell","Include the offending argument in the error message for diagnosis"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}