Bugzilla – Attachment 3199 Details for
Bug 2926
In batch mode sftp echoes the prompt and the commands back
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
allow '@' prefix to suppress command echo
bz2926.diff (text/plain), 2.36 KB, created by
Damien Miller
on 2018-11-09 14:17:29 AEDT
(
hide
)
Description:
allow '@' prefix to suppress command echo
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2018-11-09 14:17:29 AEDT
Size:
2.36 KB
patch
obsolete
>diff --git a/sftp.1 b/sftp.1 >index 0fd54ca..091ef5e 100644 >--- a/sftp.1 >+++ b/sftp.1 >@@ -127,6 +127,7 @@ at connection time (see > and > .Xr ssh-keygen 1 > for details). >+.Pp > A > .Ar batchfile > of >@@ -141,11 +142,17 @@ commands fail: > .Ic chgrp , lpwd , df , symlink , > and > .Ic lmkdir . >+.Pp > Termination on error can be suppressed on a command by command basis by > prefixing the command with a > .Sq \- > character (for example, > .Ic -rm /tmp/blah* ) . >+Echo of the command may be suppressed by prefixing the command with a >+.Sq @ >+character. >+These two prefixes may be combined in any order, for example >+.Ic -@ls /bsd . > .It Fl C > Enables compression (via ssh's > .Fl C >diff --git a/sftp.c b/sftp.c >index 9f2c0a6..106bb26 100644 >--- a/sftp.c >+++ b/sftp.c >@@ -1282,13 +1282,22 @@ parse_args(const char **cpp, int *ignore_errors, int *aflag, > /* Skip leading whitespace */ > cp = cp + strspn(cp, WHITESPACE); > >- /* Check for leading '-' (disable error processing) */ >+ /* >+ * Check for leading '-' (disable error processing) and '@' (suppress >+ * command echo) >+ */ > *ignore_errors = 0; >- if (*cp == '-') { >- *ignore_errors = 1; >- cp++; >- cp = cp + strspn(cp, WHITESPACE); >+ for (;*cp != '\0'; cp++) { >+ if (*cp == '-') { >+ *ignore_errors = 1; >+ } else if (*cp == '@') { >+ /* handled elsewhere, but ignore here */ >+ } else { >+ /* all other characters terminate prefix processing */ >+ break; >+ } > } >+ cp = cp + strspn(cp, WHITESPACE); > > /* Ignore blank lines and lines which begin with comment '#' char */ > if (*cp == '\0' || *cp == '#') >@@ -2167,7 +2176,6 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2) > interactive = !batchmode && isatty(STDIN_FILENO); > err = 0; > for (;;) { >- char *cp; > const char *line; > int count = 0; > >@@ -2181,7 +2189,8 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2) > printf("\n"); > break; > } >- if (!interactive) { /* Echo command */ >+ /* Echo command in batchmode unless asked to suppress */ >+ if (!interactive && *cmd != '@') { > mprintf("sftp> %s", cmd); > if (strlen(cmd) > 0 && > cmd[strlen(cmd) - 1] != '\n') >@@ -2200,9 +2209,7 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2) > } > } > >- cp = strrchr(cmd, '\n'); >- if (cp) >- *cp = '\0'; >+ cmd[strcspn(cmd, "\n")] = '\0'; > > /* Handle user interrupts gracefully during commands */ > interrupted = 0;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2926
:
3199
|
3200