Fixed 'echo.' and 'echoerr.'

svn path=/trunk/; revision=1267
This commit is contained in:
Eric Kohl 2000-07-19 06:58:13 +00:00
parent fb416bf8e2
commit 6041051d6a
9 changed files with 121 additions and 85 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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 */

View file

@ -1,2 +1,2 @@
#define CMD_VER "0.1"
#define CMD_VER "0.1.1"
#define CMD_VER_RC CMD_VER"\0"

View file

@ -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 <ekohl@abo.rhein-zeitung.de>)
* Unicode and redirection ready!
*
* 13-Jul-2000 (Eric Kohl <ekohl@rz-online.de>)
* 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;
}

View file

@ -361,3 +361,7 @@ o Improved COLOR command.
09-Apr-2000 ReactOS CMD version 0.1 (EricKohl <ekohl@rz-online.de>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o Fixed bug in COPY command. CMD crashed if source file didn't exist.
13-Jul-2000 ReactOS CMD version 0.1.1 (EricKohl <ekohl@rz-online.de>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o Implemented 'ECHO.' and 'ECHOERR.' commands.

View file

@ -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;
}

View file

@ -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 <hansp@digiweb.com>
ReactOS developers:
Eric Kohl <ekohl@abo.rhein-zeitung.de>
Eric Kohl <ekohl@rz-online.de>
Emanuele Aliberti <ea@iol.it>
Paolo Pantaleo <paolopan@freemail.it>
Bugs
~~~~
Batch file handling is still untested or buggy. Please report
any bug you find.
Please report bugs to Eric Kohl <ekohl@abo.rhein-zeitung.de>.
Please report bugs to Eric Kohl <ekohl@rz-online.de>.
Good luck

View file

@ -12,4 +12,4 @@ Wishlist for ReactOS CMD
More ideas?
Eric Kohl <ekohl@abo.rhein-zeitung.de>
Eric Kohl <ekohl@rz-online.de>