diff --git a/reactos/base/shell/cmd/cmdtable.c b/reactos/base/shell/cmd/cmdtable.c index 9fc7cd25357..516844fa312 100644 --- a/reactos/base/shell/cmd/cmdtable.c +++ b/reactos/base/shell/cmd/cmdtable.c @@ -120,7 +120,7 @@ COMMAND cmds[] = {_T("history"), 0, CommandHistory}, #endif -// {_T("if"), 0, cmd_if}, + {_T("if"), 0, cmd_if}, #ifdef INCLUDE_CMD_LABEL {_T("label"), 0, cmd_label}, diff --git a/reactos/base/shell/cmd/if.c b/reactos/base/shell/cmd/if.c index c462ce02710..ae848e8e0c8 100644 --- a/reactos/base/shell/cmd/if.c +++ b/reactos/base/shell/cmd/if.c @@ -49,13 +49,8 @@ static INT GenericCmp(INT (*StringCmp)(LPCTSTR, LPCTSTR), return StringCmp(Left, Right); } -BOOL ExecuteIf(PARSED_COMMAND *Cmd) +INT cmd_if (LPTSTR param) { - INT result = FALSE; /* when set cause 'then' clause to be executed */ - LPTSTR param; - -#if 0 - /* FIXME: need to handle IF /?; will require special parsing */ TRACE ("cmd_if: (\'%s\')\n", debugstr_aw(param)); if (!_tcsncmp (param, _T("/?"), 2)) @@ -63,7 +58,15 @@ BOOL ExecuteIf(PARSED_COMMAND *Cmd) ConOutResPaging(TRUE,STRING_IF_HELP1); return 0; } -#endif + + error_syntax(param); + return 1; +} + +BOOL ExecuteIf(PARSED_COMMAND *Cmd) +{ + INT result = FALSE; /* when set cause 'then' clause to be executed */ + LPTSTR param; if (Cmd->If.Operator == IF_CMDEXTVERSION) { diff --git a/reactos/base/shell/cmd/parser.c b/reactos/base/shell/cmd/parser.c index 7c35a57e5d6..6bbee17358b 100644 --- a/reactos/base/shell/cmd/parser.c +++ b/reactos/base/shell/cmd/parser.c @@ -332,7 +332,7 @@ static PARSED_COMMAND *ParseIf(void) memset(Cmd, 0, sizeof(PARSED_COMMAND)); Cmd->Type = C_IF; - int Type = ParseToken(0, STANDARD_SEPS); + int Type = CurrentTokenType; if (_tcsicmp(CurrentToken, _T("/I")) == 0) { Cmd->If.Flags |= IFFLAG_IGNORECASE; @@ -488,13 +488,19 @@ static PARSED_COMMAND *ParseCommandPart(void) /* Check for special forms */ if (_tcsicmp(ParsedLine, _T("if")) == 0) { - if (RedirList) + ParseToken(0, STANDARD_SEPS); + /* Do special parsing only if it's not followed by /? */ + if (_tcscmp(CurrentToken, _T("/?")) != 0) { - ParseError(); - FreeRedirection(RedirList); - return NULL; + if (RedirList) + { + ParseError(); + FreeRedirection(RedirList); + return NULL; + } + return ParseIf(); } - return ParseIf(); + Pos = _stpcpy(Pos, _T(" /?")); } /* Now get the tail */