From 6041051d6a8449865f261f5ac23d448fba3ff65b Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 19 Jul 2000 06:58:13 +0000 Subject: [PATCH] Fixed 'echo.' and 'echoerr.' svn path=/trunk/; revision=1267 --- rosapps/cmd/cmd.c | 62 +++++++++++++++++----------------------- rosapps/cmd/cmd.h | 5 +++- rosapps/cmd/cmdtable.c | 32 +++++++++++++++++++++ rosapps/cmd/cmdver.h | 2 +- rosapps/cmd/echo.c | 59 +++++++++++++++++++++++++++----------- rosapps/cmd/history.txt | 4 +++ rosapps/cmd/internal.c | 25 +--------------- rosapps/cmd/readme.txt | 15 +++++----- rosapps/cmd/wishlist.txt | 2 +- 9 files changed, 121 insertions(+), 85 deletions(-) diff --git a/rosapps/cmd/cmd.c b/rosapps/cmd/cmd.c index 165a006752d..25c639c1cec 100644 --- a/rosapps/cmd/cmd.c +++ b/rosapps/cmd/cmd.c @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.21 2000/05/26 06:06:05 phreak Exp $ +/* $Id: cmd.c,v 1.22 2000/07/19 06:58:12 ekohl Exp $ * * CMD.C - command-line interface. * @@ -898,27 +898,9 @@ VOID RemoveBreakHandler (VOID) static VOID ShowCommands (VOID) { - LPCOMMAND cmdptr; - INT y; - + /* print command list */ ConOutPrintf (_T("\nInternal commands available:\n")); - y = 0; - cmdptr = cmds; - while (cmdptr->name) - { - if (++y == 8) - { - ConOutPuts (cmdptr->name); - y = 0; - } - else - ConOutPrintf (_T("%-10s"), cmdptr->name); - - cmdptr++; - } - - if (y != 0) - ConOutChar ('\n'); + PrintCommandList (); /* print feature list */ ConOutPuts ("\nFeatures available:"); @@ -1024,28 +1006,38 @@ Initialize (int argc, char *argv[]) { /* This just runs a program and exits */ ++i; - _tcscpy (commandline, argv[i]); - while (argv[++i]) + if (argv[i]) { - _tcscat (commandline, " "); - _tcscat (commandline, argv[i]); - } + _tcscpy (commandline, argv[i]); + while (argv[++i]) + { + _tcscat (commandline, " "); + _tcscat (commandline, argv[i]); + } - ParseCommandLine(commandline); - ExitProcess (ProcessInput (TRUE)); + ParseCommandLine(commandline); + ExitProcess (ProcessInput (TRUE)); + } + else + { + ExitProcess (0); + } } else if (!_tcsicmp (argv[i], _T("/k"))) { /* This just runs a program and remains */ ++i; - _tcscpy (commandline, argv[i]); - while (argv[++i]) + if (argv[i]) { - _tcscat (commandline, " "); - _tcscat (commandline, argv[i]); - } + _tcscpy (commandline, argv[i]); + while (argv[++i]) + { + _tcscat (commandline, " "); + _tcscat (commandline, argv[i]); + } - ParseCommandLine(commandline); + ParseCommandLine(commandline); + } } #ifdef INCLUDE_CMD_COLOR else if (!_tcsnicmp (argv[i], _T("/t:"), 3)) @@ -1174,7 +1166,7 @@ int main (int argc, char *argv[]) SetFileApisToOEM (); if( GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &Info ) == FALSE ) - printf( "GetConsoleScreenBufferInfo: Error: %d\n", GetLastError() ); + printf( "GetConsoleScreenBufferInfo: Error: %ld\n", GetLastError() ); wColor = Info.wAttributes; wDefColor = wColor; /* check switches on command-line */ diff --git a/rosapps/cmd/cmd.h b/rosapps/cmd/cmd.h index e599ce5159a..3252b1b3348 100644 --- a/rosapps/cmd/cmd.h +++ b/rosapps/cmd/cmd.h @@ -1,4 +1,4 @@ -/* $Id: cmd.h,v 1.19 2000/02/01 18:29:11 paolopan Exp $ +/* $Id: cmd.h,v 1.20 2000/07/19 06:58:13 ekohl Exp $ * * CMD.H - header file for the modules in CMD.EXE * @@ -125,6 +125,7 @@ VOID ReadCommand (LPTSTR, INT); /* Prototypes for CMDTABLE.C */ #define CMD_SPECIAL 1 #define CMD_BATCHONLY 2 +#define CMD_HIDE 4 typedef struct tagCOMMAND { @@ -135,6 +136,8 @@ typedef struct tagCOMMAND extern COMMAND cmds[]; /* The internal command table */ +VOID PrintCommandList (VOID); + /* Prototypes for COLOR.C */ VOID SetScreenColor(WORD wArgColor, BOOL bFill); diff --git a/rosapps/cmd/cmdtable.c b/rosapps/cmd/cmdtable.c index 34d973869fd..7087a7de56c 100644 --- a/rosapps/cmd/cmdtable.c +++ b/rosapps/cmd/cmdtable.c @@ -97,8 +97,10 @@ COMMAND cmds[] = #endif {_T("echo"), 0, CommandEcho}, + {_T("echo."), CMD_HIDE, CommandEcho}, {_T("echos"), 0, CommandEchos}, {_T("echoerr"), 0, CommandEchoerr}, + {_T("echoerr."), CMD_HIDE, CommandEchoerr}, {_T("echoserr"), 0, CommandEchoserr}, #ifdef INCLUDE_CMD_DEL @@ -228,4 +230,34 @@ COMMAND cmds[] = {NULL, 0, NULL} }; + +VOID PrintCommandList (VOID) +{ + LPCOMMAND cmdptr; + INT y; + + y = 0; + cmdptr = cmds; + while (cmdptr->name) + { + if (!(cmdptr->flags & CMD_HIDE)) + { + if (++y == 8) + { + ConOutPuts (cmdptr->name); + y = 0; + } + else + { + ConOutPrintf (_T("%-10s"), cmdptr->name); + } + } + + cmdptr++; + } + + if (y != 0) + ConOutChar ('\n'); +} + /* EOF */ diff --git a/rosapps/cmd/cmdver.h b/rosapps/cmd/cmdver.h index 9b11b0f3d0e..45ec120e2a5 100644 --- a/rosapps/cmd/cmdver.h +++ b/rosapps/cmd/cmdver.h @@ -1,2 +1,2 @@ -#define CMD_VER "0.1" +#define CMD_VER "0.1.1" #define CMD_VER_RC CMD_VER"\0" diff --git a/rosapps/cmd/echo.c b/rosapps/cmd/echo.c index 6ae2d5e1240..7e9b567f095 100644 --- a/rosapps/cmd/echo.c +++ b/rosapps/cmd/echo.c @@ -1,4 +1,4 @@ -/* $Id: echo.c,v 1.3 1999/10/03 22:15:33 ekohl Exp $ +/* $Id: echo.c,v 1.4 2000/07/19 06:58:13 ekohl Exp $ * * ECHO.C - internal echo commands. * @@ -19,6 +19,9 @@ * * 19-Jan-1999 (Eric Kohl ) * Unicode and redirection ready! + * + * 13-Jul-2000 (Eric Kohl ) + * Implemented 'echo.' and 'echoerr.'. */ #include "config.h" @@ -39,20 +42,34 @@ INT CommandEcho (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - ConOutPuts ("Displays a message or switches command echoing on or off.\n\n" - "ECHO [ON | OFF]\nECHO [message]\n\n" - "Type ECHO without a parameter to display the current ECHO setting."); + ConOutPuts ("Displays a message or switches command echoing on or off.\n" + "\n" + " ECHO [ON | OFF]\n" + " ECHO [message]\n" + " ECHO. prints an empty line\n" + "\n" + "Type ECHO without a parameter to display the current ECHO setting."); return 0; } - if (_tcsicmp (param, D_OFF) == 0) - bEcho = FALSE; - else if (_tcsicmp (param, D_ON) == 0) - bEcho = TRUE; - else if (*param) - ConOutPuts (param); + if (_tcsicmp (cmd, _T("echo.")) == 0) + { + if (param[0] == 0) + ConOutChar (_T('\n')); + else + ConOutPuts (param); + } else - ConOutPrintf (_T("ECHO is %s\n"), bEcho ? D_ON : D_OFF); + { + if (_tcsicmp (param, D_OFF) == 0) + bEcho = FALSE; + else if (_tcsicmp (param, D_ON) == 0) + bEcho = TRUE; + else if (*param) + ConOutPuts (param); + else + ConOutPrintf (_T("ECHO is %s\n"), bEcho ? D_ON : D_OFF); + } return 0; } @@ -67,7 +84,7 @@ INT CommandEchos (LPTSTR cmd, LPTSTR param) { ConOutPuts ("Display a messages without trailing carridge return and line feed.\n" "\n" - "ECHOS message\n"); + " ECHOS message"); return 0; } @@ -88,12 +105,22 @@ INT CommandEchoerr (LPTSTR cmd, LPTSTR param) { ConOutPuts ("Displays a message to the standard error.\n" "\n" - "ECHOERR message"); + " ECHOERR message\n" + " ECHOERR. prints an empty line"); return 0; } - if (*param) + if (_tcsicmp (cmd, _T("echoerr.")) == 0) + { + if (param[0] == 0) + ConErrChar (_T('\n')); + else + ConErrPuts (param); + } + else if (*param) + { ConErrPuts (param); + } return 0; } @@ -108,12 +135,12 @@ INT CommandEchoserr (LPTSTR cmd, LPTSTR param) { ConOutPuts ("Prints a messages to standard error output without trailing carridge return and line feed.\n" "\n" - "ECHOSERR message\n"); + " ECHOSERR message"); return 0; } if (*param) - ConOutPrintf ("%s", param); + ConOutPrintf (_T("%s"), param); return 0; } diff --git a/rosapps/cmd/history.txt b/rosapps/cmd/history.txt index c1dfa614a0e..a0cac6f59d1 100644 --- a/rosapps/cmd/history.txt +++ b/rosapps/cmd/history.txt @@ -361,3 +361,7 @@ o Improved COLOR command. 09-Apr-2000 ReactOS CMD version 0.1 (EricKohl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ o Fixed bug in COPY command. CMD crashed if source file didn't exist. + +13-Jul-2000 ReactOS CMD version 0.1.1 (EricKohl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +o Implemented 'ECHO.' and 'ECHOERR.' commands. diff --git a/rosapps/cmd/internal.c b/rosapps/cmd/internal.c index 8bdaa6c9a16..f7ea056fd46 100644 --- a/rosapps/cmd/internal.c +++ b/rosapps/cmd/internal.c @@ -132,9 +132,6 @@ #include "cmd.h" -extern COMMAND cmds[]; /* The internal command table, used in '?' */ - - #ifdef INCLUDE_CMD_CHDIR static LPTSTR lpLastPath; @@ -473,27 +470,7 @@ INT CommandRem (LPTSTR cmd, LPTSTR param) INT CommandShowCommands (LPTSTR cmd, LPTSTR param) { - LPCOMMAND cmdptr; - INT y; - - y = 0; - cmdptr = cmds; - while (cmdptr->name) - { - if (++y == 8) - { - ConOutPuts (cmdptr->name); - y = 0; - } - else - ConOutPrintf (_T("%-10s"), cmdptr->name); - - cmdptr++; - } - - if (y != 0) - ConOutChar (_T('\n')); - + PrintCommandList (); return 0; } diff --git a/rosapps/cmd/readme.txt b/rosapps/cmd/readme.txt index b72625e6c20..37bf9a9a7e7 100644 --- a/rosapps/cmd/readme.txt +++ b/rosapps/cmd/readme.txt @@ -1,5 +1,5 @@ -ReactOS command line interpreter CMD version 0.1 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ReactOS command line interpreter CMD version 0.1.1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ReactOS command line interpreter CMD is derived from FreeCOM, the FreeDOS command line interpreter. @@ -13,7 +13,7 @@ Compiling Cmd can be built in two different versions. A full version for use under Windows 9x or Windows NT and a reduced version for use under ReactOS. -Note: The full version won't runder ReactOS and the reduced version is not +Note: The full version won't run on ReactOS and the reduced version is not usable under Win 9x/NT. To build the full version, make sure the symbol '__REACTOS__' is NOT defined @@ -25,7 +25,6 @@ in 'rosapps/cmd/config.h' line 13. Current Features ~~~~~~~~~~~~~~~~ - - environment handling with prompt and path support. - directory utilities. - command-line history with doskey-like features. @@ -33,11 +32,11 @@ Current Features - input/output redirection and piping. - alias support. - filename completion (use TAB) + (this is still incomplete) Credits ~~~~~~~ - FreeDOS developers: normat@rpi.edu (Tim Norman) mrains@apanix.apana.org.au (Matt Rains) @@ -52,15 +51,17 @@ FreeDOS developers: Hans B Pufal ReactOS developers: - Eric Kohl + Eric Kohl Emanuele Aliberti Paolo Pantaleo Bugs ~~~~ +Batch file handling is still untested or buggy. Please report +any bug you find. -Please report bugs to Eric Kohl . +Please report bugs to Eric Kohl . Good luck diff --git a/rosapps/cmd/wishlist.txt b/rosapps/cmd/wishlist.txt index 65c518d08f8..732ab451b34 100644 --- a/rosapps/cmd/wishlist.txt +++ b/rosapps/cmd/wishlist.txt @@ -12,4 +12,4 @@ Wishlist for ReactOS CMD More ideas? - Eric Kohl \ No newline at end of file + Eric Kohl