diff options
author | Mattias Andrée <m@maandree.se> | 2025-02-08 16:43:41 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-02-08 16:43:41 +0100 |
commit | 521fbb5a8294f4ad924e10bcc871c95be12957ba (patch) | |
tree | 74923bb8092173a77082a2af0081014e2a89cc3f /sshexec.c | |
parent | Update README (diff) | |
download | sshexec-521fbb5a8294f4ad924e10bcc871c95be12957ba.tar.gz sshexec-521fbb5a8294f4ad924e10bcc871c95be12957ba.tar.bz2 sshexec-521fbb5a8294f4ad924e10bcc871c95be12957ba.tar.xz |
Add cd option
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'sshexec.c')
-rw-r--r-- | sshexec.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -19,7 +19,7 @@ static void usage(void) { exitf("usage: %s [{ %s }] [ssh-option] ... destination command [argument] ...\n", - argv0, "[ssh=command] [dir=directory] [[fd]{>,>>,>|,<>}[&]=file]"); + argv0, "[ssh=command] [dir=directory] [cd=(strict|lax)] [[fd]{>,>>,>|,<>}[&]=file]"); } @@ -129,6 +129,7 @@ main(int argc_unused, char *argv[]) { const char *dir = NULL; const char *ssh = NULL; + const char *cd = NULL; struct redirection *redirections = NULL; size_t nredirections = 0; char *destination; @@ -140,6 +141,7 @@ main(int argc_unused, char *argv[]) char opt; const char **args; size_t i; + int strict_cd; (void) argc_unused; @@ -158,6 +160,7 @@ main(int argc_unused, char *argv[]) for (; *argv && strcmp(*argv, "}"); argv++) { STORE_OPT(&ssh, "ssh") STORE_OPT(&dir, "dir") + STORE_OPT(&cd, "cd") p = *argv; while (isdigit(*p)) @@ -202,6 +205,13 @@ main(int argc_unused, char *argv[]) if (!ssh) ssh = "ssh"; + if (!cd || !strcmp(cd, "strict")) + strict_cd = 1; + else if (!strcmp(cd, "lax")) + strict_cd = 0; + else + usage(); + opts = argv; nopts = 0; while (*argv) { @@ -263,7 +273,7 @@ dest_dir_checked: if (dir) { build_command_asis("cd -- "); build_command_escape(dir); - build_command_asis(" && "); + build_command_asis(strict_cd ? " && " : " ; "); } build_command_asis("exec env --"); for (; *argv; argv++) { |