Batch mode is meant for script automation, not human operations, so echoing the prompt and the commands doesn't make any sense and needs extra stuff while programatically processing the output A possible solution that's also backward compatible with all uses of the batch mode is to allow for a special prefix character to commands to avoid any echoing, just like the "-" is used to avoid a single failing command to terminate the session. Something like "@" or "#" would be ok IMHO. For example, the command syntax could become: [@][-]<command> [arguments]... The current workaround is to expunge every first output line, but am not sure whether this can apply to all use cases.
Created attachment 3199 [details] allow '@' prefix to suppress command echo The prefix is a good idea. This implements '@command' to suppress echo.
Comment on attachment 3199 [details] allow '@' prefix to suppress command echo >+ if (!interactive && *cmd != '@') { > mprintf("sftp> %s", cmd); You're only checking the first character but the man page says - and @ can be supplied in any order, so -@ is not going to do what the man page says.
Created attachment 3200 [details] Allow @ and - to appear in any order Darren points out that, despite what I advertised in the manpage, my previous patch did not allow '-' and '@' to appear in any order. This fixes this by moving the echo until after the entire command has been parsed.
Patch is committed and will be in OpenSSH 8.0
At the section "Lines 1282-1294 parse_args(const char **cpp, int *ignore_errors, int *aflag," I see a possible bug. You can intercept the "-" and the "@" at any place in the command string. Which can lead to unwanted results. IMHO the correct code could begin with something like: for (char* cpend=cp+2;*cp != '\0' && cp < cpend; cp++) {
closing resolved bugs as of 8.6p1 release
[spam removed]