From: Ken Sharp Subject: cmd: Add /? option Message-Id: <506A490C.8050007@o2.co.uk> Date: Tue, 02 Oct 2012 02:53:16 +0100 cmd /? should print help for cmd.exe. The attached patch does this. I have only included the switches that are currently supported in Wine. There are many more in the modern versions of Windows. A cmd /? in Windows XP reveals a LOT of information about those options. Fixes Bug 28021. From b937eaab3befc09a637883aa5f55a516a0761ad0 Mon Sep 17 00:00:00 2001 From: Ken Sharp Date: Tue, 2 Oct 2012 01:15:14 +0000 Subject: [PATCH] cmd: Add /? option --- programs/cmd/cmd.rc | 9 +++++++++ programs/cmd/wcmd.h | 1 + programs/cmd/wcmdmain.c | 14 +++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/programs/cmd/cmd.rc b/programs/cmd/cmd.rc index 6e63936..5dd9324 100644 --- a/programs/cmd/cmd.rc +++ b/programs/cmd/cmd.rc @@ -353,4 +353,13 @@ Enter HELP for further information on any of the above commands.\n" WCMD_VOLUMENOLABEL, "Volume in drive %1!c! has no label.\n" WCMD_YESNO, " (Yes|No)" WCMD_YESNOALL, " (Yes|No|All)" + + WCMD_OPTIONS_HELP, "Usage: cmd [/?] [/s] [/q] [/c command | /k command] \n\n\ +/?\tShow this help\n\ +/c\tRun command and exit\n\ +/k\tRun command and return to the CMD prompt\n\ +/s\tStrip the first set of quote characters from the command\n\ +/q\tTurn echo off\n\n\ +If /c or /k is specified then everything following is considered the command.\n\ +Quotes are required to deal with the special characters &()[]{}^=;!'+,`~ and spaces.\n" } diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 451c49b..c9edeea 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -283,3 +283,4 @@ extern WCHAR version_string[]; #define WCMD_VOLUMENOLABEL 1037 #define WCMD_YESNO 1038 #define WCMD_YESNOALL 1039 +#define WCMD_OPTIONS_HELP 1040 diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 82ec153..37bef61 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -47,7 +47,7 @@ WCHAR anykey[100], version_string[100]; const WCHAR newlineW[] = {'\r','\n','\0'}; const WCHAR spaceW[] = {' ','\0'}; -static BOOL opt_c, opt_k, opt_s, unicodeOutput = FALSE; +static BOOL opt_c, opt_k, opt_s, opt_help, unicodeOutput = FALSE; /* Variables pertaining to paging */ static BOOL paged_mode; @@ -2318,7 +2318,7 @@ int wmain (int argc, WCHAR *argvW[]) cmd = NULL; args = argc; - opt_c = opt_k = opt_q = opt_s = FALSE; + opt_c = opt_k = opt_q = opt_s = opt_help = FALSE; while (args > 0) { WCHAR c; @@ -2346,13 +2346,21 @@ int wmain (int argc, WCHAR *argvW[]) opt_t=strtoulW(&(*argvW)[3], NULL, 16); } else if (tolowerW(c)=='x' || tolowerW(c)=='y') { /* Ignored for compatibility with Windows */ + } else if (c=='?') { + opt_help = TRUE; + } + + /* If /? help should be printed and then exit */ + if(opt_help) { + WCMD_output(WCMD_LoadMessage(WCMD_OPTIONS_HELP)); + exit(0); } if ((*argvW)[2]==0) { argvW++; args--; } - else /* handle `cmd /cnotepad.exe` and `cmd /x/c ...` */ + else /* handle `cmd /c notepad.exe` and `cmd /x/c ...` */ { *argvW+=2; } -- 1.7.9.5