diff cli-main.c @ 1516:33b872649eb7

Add dbclient '-J &fd' option for a file descriptor Based on patch by Harald Becker
author Matt Johnston <matt@ucc.asn.au>
date Sun, 18 Feb 2018 15:12:15 +0800
parents 0c16b4ccbd54
children d5cdc60db08e
line wrap: on
line diff
--- a/cli-main.c	Sun Feb 18 11:22:13 2018 +0800
+++ b/cli-main.c	Sun Feb 18 15:12:15 2018 +0800
@@ -158,6 +158,21 @@
 	size_t ex_cmdlen;
 	int ret;
 
+	/* File descriptor "-j &3" */
+	if (*cli_opts.proxycmd == '&') {
+		char *p = cli_opts.proxycmd + 1;
+		int sock = strtoul(p, &p, 10);
+		/* must be a single number, and not stdin/stdout/stderr */
+		if (sock > 2 && sock < 1024 && *p == '\0') {
+			*sock_in = sock;
+			*sock_out = sock;
+			return;
+		}
+	}
+
+	/* Normal proxycommand */
+
+	/* So that spawn_command knows which shell to run */
 	fill_passwd(cli_opts.own_user);
 
 	ex_cmdlen = strlen(cli_opts.proxycmd) + 6; /* "exec " + command + '\0' */