Skip to content

Commit a3fbfad

Browse files
committed
shell escape commands
1 parent 7326c6f commit a3fbfad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/commands/ssh.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ const ssh = async (args: yargs.ArgumentsCamelCase<SshCommandArgs>) => {
137137
id,
138138
// the command to run on the remote machine, if any
139139
command: args.command
140-
? `${args.command} ${args.arguments.join(" ")}`.trim()
140+
? `${args.command} ${args.arguments.map(shellEscapeArgument).join(" ")}`.trim()
141141
: undefined,
142142
});
143143
};
144+
145+
// Helper function to support double quotes (") in commands such as `p0 ssh <instance>> echo 'hi; "mom"'`
146+
const shellEscapeArgument = (argument: string) => {
147+
return `"${argument.replace('"', '\\"')}"`;
148+
};

0 commit comments

Comments
 (0)