From 2c975497a5d6e5ed5a5648668f76f0d7d000fd9c Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 10 Dec 2001 17:50:03 +0000 Subject: [PATCH] RDB's patch to allow the `-c' option to Pageant to take a command _with arguments_. Duh, should have thought of that myself. git-svn-id: svn://svn.tartarus.org/sgt/putty@1467 cda61777-01e9-0310-a592-d414129be87e --- pageant.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pageant.c b/pageant.c index d249fab4..2cfcdd0b 100644 --- a/pageant.c +++ b/pageant.c @@ -1418,10 +1418,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, /* * Fork and Exec the command in cmdline. [DBW] */ -void spawn_cmd(char *cmdline, int show) +void spawn_cmd(char *cmdline, char * args, int show) { if (ShellExecute(NULL, _T("open"), cmdline, - NULL, NULL, show) <= (HINSTANCE) 32) { + args, NULL, show) <= (HINSTANCE) 32) { TCHAR sMsg[140]; sprintf(sMsg, _T("Failed to run \"%.100s\", Error: %d"), cmdline, (int)GetLastError()); @@ -1583,8 +1583,18 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) */ forget_passphrases(); - if (command) - spawn_cmd(command, show); + if (command) { + char *args; + if (command[0] == '"') + args = strchr(++command, '"'); + else + args = strchr(command, ' '); + if (args) { + *args++ = 0; + while(*args && isspace(*args)) args++; + } + spawn_cmd(command, args, show); + } /* * If Pageant was already running, we leave now. If we haven't -- 2.11.0