diff options
-rw-r--r-- | README | 11 | ||||
-rw-r--r-- | sshexec.1 | 15 | ||||
-rw-r--r-- | sshexec.c | 14 |
3 files changed, 37 insertions, 3 deletions
@@ -2,7 +2,7 @@ NAME sshexec - run a command through ssh(1) with normal command syntax SYNOPSIS - sshexec [{ [ssh=ssh-command] [dir=directory] + sshexec [{ [ssh=ssh-command] [dir=directory] [cd=(strict|lax)] [[fd]{>,>>,>|,<,<>}[&]=file] }] [ssh-option] ... destination command [argument] ... @@ -43,6 +43,15 @@ OPTIONS In the remote, change working directory to directory before executing command. + cd=strict + Fail without executing the command if it's not possible + to set directory as the remote working directory. + + cd=lax + Continue (but warn) executing the command even if it's + not possible to set directory as the remote working + directory. + [fd]>=file After changing working directory (assuming one is specified), create or truncate the specified file and @@ -8,6 +8,7 @@ sshexec - run a command through ssh(1) with normal command syntax .RB [ { .RI [\fBssh=\fP ssh-command ] .RI [\fBdir=\fP directory ] +.RB [ cd= ( strict | lax )] .RB [[\fIfd\fP]{ > , >> , >| , < , <> }[ & ] = \fIfile\fP] .BR } ] .RI [ ssh-option ]\ ...\, @@ -107,6 +108,20 @@ In the remote, change working directory to before executing .IR command . .TP +.B cd=strict +Fail without executing the +.I command +if it's not possible to set +.I directory +as the remote working directory. +.TP +.B cd=lax +Continue (but warn) executing the +.I command +even if it's not possible to set +.I directory +as the remote working directory. +.TP .IB \fR[\fPfd\fP]\fP >= file After changing working directory (assuming one is specified), create or truncate the specified @@ -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++) { |