浏览代码

don't insert unnecessary linebreaks upon PassCmd invocation

the PassCmd will be typically non-interactive (or it will use a gui
password agent), so starting a new line just makes the progress counter
uglier. so make it configurable and default to no line break.
Oswald Buddenhagen 10 年之前
父节点
当前提交
95276cd967
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 8 3
      src/drv_imap.c
  2. 4 1
      src/mbsync.1

+ 8 - 3
src/drv_imap.c

@@ -1723,13 +1723,18 @@ ensure_user( imap_server_conf_t *srvc )
 static const char *
 static const char *
 ensure_password( imap_server_conf_t *srvc )
 ensure_password( imap_server_conf_t *srvc )
 {
 {
-	if (srvc->pass_cmd) {
+	char *cmd = srvc->pass_cmd;
+
+	if (cmd) {
 		FILE *fp;
 		FILE *fp;
 		int ret;
 		int ret;
 		char buffer[80];
 		char buffer[80];
 
 
-		flushn();
-		if (!(fp = popen( srvc->pass_cmd, "r" ))) {
+		if (*cmd == '+') {
+			flushn();
+			cmd++;
+		}
+		if (!(fp = popen( cmd, "r" ))) {
 		  pipeerr:
 		  pipeerr:
 			sys_error( "Skipping account %s, password command failed", srvc->name );
 			sys_error( "Skipping account %s, password command failed", srvc->name );
 			return 0;
 			return 0;

+ 4 - 1
src/mbsync.1

@@ -288,11 +288,14 @@ If neither a password nor a password command is specified in the
 configuration file, \fBmbsync\fR will prompt you for a password.
 configuration file, \fBmbsync\fR will prompt you for a password.
 ..
 ..
 .TP
 .TP
-\fBPassCmd\fR \fIcommand\fR
+\fBPassCmd\fR [\fB+\fR]\fIcommand\fR
 Specify a shell command to obtain a password rather than specifying a
 Specify a shell command to obtain a password rather than specifying a
 password directly. This allows you to use password files and agents.
 password directly. This allows you to use password files and agents.
 The command must produce exactly one line on stdout; the trailing newline is
 The command must produce exactly one line on stdout; the trailing newline is
 optional.
 optional.
+Prepend \fB+\fR to the command to indicate that it produces TTY output
+(e.g., a decryption password prompt); failure to do so will merely produce
+messier output.
 ..
 ..
 .TP
 .TP
 \fBTunnel\fR \fIcommand\fR
 \fBTunnel\fR \fIcommand\fR