reactos/base/shell/cmd
Hermès Bélusca-Maïto 5d5a1a455c
[CMD] FOR: Fix a bug when parsing the "delims=" option in FOR loops.
Suppose the following FOR-loop command, to be run from the command-line
(if using a batch file, double each percent '%' sign):

  FOR %l IN ("a,b,c,d,e" "f,g,h,i,j") DO (
    FOR /F "delims=, tokens=1-3*" %a IN (%l) DO @echo %a-%b-%c-%d
  )

The outermost FOR-loop enumerates the two strings "a,b,c,d,e" and
"f,g,h,i,j" (placed in %l), and parse each of these in turn, splitting
them at each specified delimiter (here only one character) ',' and storing
the results in consecutive tokens %a, %b, %c, %d, with the last token %d
containing all the remaining string (non-split).
The expected result is:

  a-b-c-d,e
  f-g-h-i,j

However, due to the way the delimiters string specified by the "delims="
option is stored (no stack/heap duplication of the FOR-option substring,
but reading from it directly), during the first run of the innermost
FOR-loop, the option string "delims=, tokens=1-3*" was truncated to just
after the ',' due to the erroneous "delims=" parsing, so that when this
FOR-loop ran for a second time (to deal with the second string), the option
string was already erroneously truncated, without the "tokens=..." part,
so that the parsing results were not stored in the tokens and resulting in:

  a-b-c-d,e
  f-%b-%c-%d

instead. The solution is to save where the "delims=" string needs to be
cut, but wait until running the actual FOR-loop to terminate it (and
saving the original character too), run the FOR-loop body, and then
restore the original character where termination took place. This allows
having the FOR-loop option string valid for the next execution of the
FOR-loop.
2020-09-19 19:44:56 +02:00
..
lang [BASE] Improve Spanish (es-ES) translation (#3088) 2020-08-25 18:10:23 +03:00
res Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
alias.c [CMD] Add missing memory allocation NULL checks (#161). CORE-8304 2018-08-21 14:02:24 +02:00
assoc.c [CMD] Add missing memory allocation NULL checks (#161). CORE-8304 2018-08-21 14:02:24 +02:00
batch.c [CMD] Some fixes for getting the enhanced '%~XXX' batch/FOR variables. 2020-09-19 19:44:54 +02:00
batch.h [CMD] Some fixes for getting the enhanced '%~XXX' batch/FOR variables. 2020-09-19 19:44:54 +02:00
beep.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
call.c [CMD] Additional fixes for ERRORLEVEL and last returned exit code from EXIT, CALL commands and CMD. 2020-08-19 20:36:03 +02:00
choice.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
cls.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
CMakeLists.txt [CMD] Remove deprecated definition in CMakeLists.txt. 2020-08-19 20:35:52 +02:00
cmd.c [CMD] Code formatting in SubstituteVar(). 2020-09-19 19:44:55 +02:00
cmd.h [CMD] Fix delayed expansion of variables. 2020-09-19 19:44:55 +02:00
cmd.rc [CMD] Update the documentation of the FOR command. CORE-5806 2017-11-21 23:47:46 +01:00
cmddbg.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
cmddbg.h Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
cmdinput.c [CMD] Do not overwrite input string on Ctrl+C (#852) 2018-09-13 11:47:01 +02:00
cmdtable.c [LABEL][CMD] Convert the label command to a standalone executable 2019-09-22 14:51:23 +02:00
cmdver.h Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
color.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
config.h [LABEL][CMD] Convert the label command to a standalone executable 2019-09-22 14:51:23 +02:00
console.c [CONUTILS] Diverse improvements: start doxygenating and add some resource messsage helper functions. 2018-02-02 00:41:54 +01:00
console.h Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
copy.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
ctty.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
date.c [CMD] DATE: Simplify the input loop, based on the TIME command. 2020-08-19 20:36:10 +02:00
del.c [CMD] Fix the ErrorMessage() function. 2020-05-18 02:21:56 +02:00
delay.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
dir.c [CMD] Correctly parse drive-decorated pathname (#2382) 2020-02-26 22:28:02 +09:00
dirstack.c [CMD] Add missing memory allocation NULL checks (#161). CORE-8304 2018-08-21 14:02:24 +02:00
echo.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
error.c [CMD] Use pointers to const strings in error functions, where applicable. 2020-09-13 22:50:09 +02:00
filecomp.c [CMD] Code formatting for IsValidPathName, IsExistingFile, IsExistingDirectory, and use INVALID_FILE_ATTRIBUTES instead of an hardcoded value. 2020-09-04 00:24:45 +02:00
files.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
for.c [CMD] FOR: Fix a bug when parsing the "delims=" option in FOR loops. 2020-09-19 19:44:56 +02:00
free.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
goto.c [CMD] GOTO: Fix label parsing. 2020-08-19 20:36:01 +02:00
history.c [CMD] HISTORY: Fix command output (missing linefeed) (#3205) 2020-09-18 00:17:08 +02:00
history.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
if.c [CMD] Code formatting for IsValidPathName, IsExistingFile, IsExistingDirectory, and use INVALID_FILE_ATTRIBUTES instead of an hardcoded value. 2020-09-04 00:24:45 +02:00
internal.c [CMD] CHDIR: Some features are available only when extensions are enabled. Update the SetRootPath() as well. 2020-08-19 21:39:21 +02:00
license.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
locale.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
memory.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
misc.c [CMD] Code formatting for IsValidPathName, IsExistingFile, IsExistingDirectory, and use INVALID_FILE_ATTRIBUTES instead of an hardcoded value. 2020-09-04 00:24:45 +02:00
mklink.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
move.c [CMD] MOVE: Set the errorlevel on failure. 2020-08-19 20:36:07 +02:00
msgbox.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
parser.c [CMD] Use pointers to const strings in error functions, where applicable. 2020-09-13 22:50:09 +02:00
path.c [CMD] PATH, SET: Fix the returned error message when an environment variable does not exist. 2020-08-19 20:36:06 +02:00
pause.c [CMD] Print a newline after the interactive 'pause' command message finishes to run. 2018-06-03 02:36:32 +02:00
precomp.h [CMD] Use string-safe call to build the new console title (possibly truncated, we don't care), avoiding any buffer overflow. Caught by David Quintana. 2018-05-20 19:57:43 +02:00
prompt.c [CMD] If the prompt displays the information line on top of the screen, ensure that the prompt won't be hidden below it. 2019-12-29 19:14:03 +01:00
readme.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
readme2.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
redir.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
ren.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
ren.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
replace.c [CMD] REPLACE: Fix a memory leak. 2020-08-19 20:36:13 +02:00
resource.h [CMD] PATH, SET: Fix the returned error message when an environment variable does not exist. 2020-08-19 20:36:06 +02:00
screen.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
set.c [CMD] SET: Fix displaying the environment variables with a given prefix. 2020-08-19 21:39:18 +02:00
setlocal.c [CMD] SETLOCAL / ENDLOCAL: Save / Restore as well the current drive and current directory. 2020-08-19 20:36:13 +02:00
shift.c [CMD] SHIFT: Use _istdigit(). 2020-09-13 22:50:10 +02:00
start.c [CMD] Add missing memory allocation NULL checks (#161). CORE-8304 2018-08-21 14:02:24 +02:00
strtoclr.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
time.c [CMD] TIME: The /T option is available only when extensions are enabled. 2020-08-19 20:36:09 +02:00
timer.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
title.c [CMD] Improve the situations when the console title can be changed. 2018-06-03 02:36:39 +02:00
todo.txt [CMD] todo.txt: Remove some points that have already been implemented since ages. 2020-08-19 20:35:52 +02:00
type.c [CMD] TYPE: Rewrite the command so as to fix some of its behaviour. 2020-08-19 21:39:22 +02:00
ver.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
verify.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
vol.c [CMD] Fix the ErrorMessage() function. 2020-05-18 02:21:56 +02:00
where.c [CMD] Add missing memory allocation NULL checks (#161). CORE-8304 2018-08-21 14:02:24 +02:00
window.c Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00

ReactOS command line interpreter CMD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ReactOS command line interpreter CMD is derived from FreeCOM, the
FreeDOS command line interpreter.

We are shooting mainly to be just like 2000/XP cmd.exe.  They are very close and only a small number(none that i can recall off the top of my head, so maybe 0) differences have been found between those two.  It has been reported that ROS cmd.exe does not work on nt4 because of a missing api.  I'm hoping to fix this at some point.


Compiling
~~~~~~~~~
ROS cmd used to depend on __REACTOS__ to provide two different ways to build cmd.  There is still code left in it for this but...  The __REACTOS__ = 0 has not been develped, maintained.  And therefore it does not even compile anymore.  __REACTOS__ = 1 works fine on both windows(nt). and someday i plan to remove all the __REACTOS__ = 0.

Using rbuild you can compile cmd separately by "make cmd_install".  Also you can compile cmd using MSVC 6 and soon 7/8 hopefully.


Current Features
~~~~~~~~~~~~~~~~
 - environment handling with prompt and path support.
 - directory utilities.
 - command-line history with doskey-like features.
 - batch file processing.
 - input/output redirection and piping.
 - alias support.
 - filename completion (use TAB), both Bash and Windows-CMD style.


Credits
~~~~~~~
FreeDOS developers:
   normat@rpi.edu (Tim Norman)
   mrains@apanix.apana.org.au (Matt Rains)
   ejeffrey@iastate.edu (Evan Jeffrey)
   Steffen.Kaiser@Informatik.TU-Chemnitz.DE (Steffen Kaiser)
   Svante Frey (sfrey@kuai.se)
   Oliver Mueller (ogmueller@t-online.de)
   Aaron Kaufman (morgan@remarque.berkeley.edu)
   Marc Desrochers (bitzero@hotmail.com)
   Rob Lake (rlake@cs.mun.ca)
   John P. Price <linux-guru@gcfl.net>
   Hans B Pufal <hansp@digiweb.com>

ReactOS developers:
   Eric Kohl
   Emanuele Aliberti <ea@iol.it>
   Paolo Pantaleo <paolopan@freemail.it>
   Brandon Turner <turnerb7@msu.edu>


Bugs
~~~~
There are still many bugs ;)
Please report bugs to ReactOS team <ros-dev@reactos.org> or to JIRA at www.reactos.org