Commit graph

50 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 51e2a35e96 [CMD-HELP]
Add a help.exe utility to replace the old built-in command "help" in cmd.exe (i.e. do it the Win2k3 way).
This way, if somebody runs a personalized command-line environment which provides its own help command, one can use the personalized help command and not the standard one (e.g. the "help" command of RosBE).

Adapted by myself from a patch by Lee Schroeder.
CORE-5701 #resolve #comment Committed in revision 59832, thanks :) I use a trick to be able to compile the utility (use: ninja cmd_help) because doing "ninja help" has a signification in ninja (signaled by AmineKhaldi).

svn path=/trunk/; revision=59832
2013-08-26 12:45:34 +00:00
Hermès Bélusca-Maïto 84e1ebcd07 [CMD]
Features-only commit:
- Fix version presentation at startup and when using the "ver" command (in French)
- Add to the prompt's command help, the fact that the $S specifier can be used to add a space.
- Implement the $I prompt specifier (see http://www.robvanderwoude.com/prompt.php), which sets
  an information line on top of the screen (à la OS/2).
  Use this new setting by default (I'm doing a poll on who loves it / hates it, and how we can improve it).
  To disable it, use the command: "prompt $p$g" (the default windows' prompt).
  To enable it, add the $s specifier to the prompt string (e.g. "prompt $i$p$g").
  For your information, OS/2 uses "prompt $i[$p]" :)

svn path=/trunk/; revision=59422
2013-07-04 01:05:14 +00:00
Hermès Bélusca-Maïto 9b6dc5bd15 [CMD]
Fix whitespace (part 2/x) (convert tabs into 4-space indent).

svn path=/trunk/; revision=59378
2013-06-29 23:50:13 +00:00
Eric Kohl d14ba6a267 [CMD]
Remove cmd_main(). Patch by Lee Schroeder.
Thanks!

CORE-7205 #resolve #comment Committed in r59101.

svn path=/trunk/; revision=59101
2013-05-29 10:56:25 +00:00
Hermès Bélusca-Maïto f22dffe66a [CMD]
- Simplify CommandColor and document it. Checking whether one sets the same color for both foreground and background is now only checked inside SetScreenColor.
Based on a patch by Victor
CORE-7191 #resolve #comment Committed in rev.59055.

- Fix handling of /T:<color> option when starting cmd.exe
- Remove unneeded error string.

svn path=/trunk/; revision=59055
2013-05-20 17:43:37 +00:00
Amine Khaldi 2bd930547c * Slap *some* sense into our header inclusions.
* This significantly shrinks the dependency tracking data and the compiled objects size, which speeds up the whole build process (especially the incremental builds) accelerating the daily development as a result.
* No intended code changes, ~27% smaller build. Enjoy ;)

svn path=/trunk/; revision=58214
2013-01-24 23:00:42 +00:00
Hermès Bélusca-Maïto 893015f03c [CMD]
- Clarify the code, no functional changes.

svn path=/trunk/; revision=57415
2012-09-28 19:36:49 +00:00
Timo Kreuzer ece4aa3f3f [CMD]
Handle the + character only optionally as a token seperator, so that other commands like rename are not affected.

svn path=/trunk/; revision=56349
2012-04-14 21:35:58 +00:00
Aleksey Bragin 7ca7ff0cbd [CMD]
- Carlo Bramix: MultiByteToWideChar() has just 6 and not 8 parameters, probably it's a forgetten copy/past from WideCharToMultiByte().
- Carlo Bramix: ConvertULargeInteger() should have its parameter 'Len' declared as UINT rather than 'INT'. This fixes a signed/unsigned mismatch warning.
See issue #5678 for more details.

svn path=/trunk/; revision=49873
2010-11-30 16:38:53 +00:00
Ged Murphy c5b25b8e9b - Move from using include guards to pragma once.
- Whilst this is non-standard and potentially makes the code less portable, it's supported by both gcc and msvc and should bringg increased compilation speed due to its optimized behaviour (doesn't need to invoke the preprocessor)
- Patch by Amine Khaldi [amine.khaldi@reactos.org]

svn path=/trunk/; revision=45685
2010-02-26 11:43:19 +00:00
Jeffrey Morlan 8cf11060a9 Various fixes to the way cmd handles errorlevel and the "return values" of commands:
- Changed type of return values from BOOL to INT, with 0 indicating success and any other value indicating failure. If the left side of an || operator returns nonzero, errorlevel is set to that value.
- The return value of a batch file or FOR is the return value of the last command executed in it. An empty batch file returns 0, unless it was CALLed, in which case it returns errorlevel.
- CALL sets errorlevel to the return value of whatever was called.
- Running a GUI program doesn't change errorlevel, but always returns 0.
- CMD /C uses the command's return value, not errorlevel, as the process exit code.

svn path=/trunk/; revision=40474
2009-04-12 23:51:15 +00:00
Sylvain Petreolle 3d1ed5b157 fix cmd build
svn path=/trunk/; revision=40459
2009-04-11 16:37:08 +00:00
Jeffrey Morlan 9f0ebd0b54 - Simplified code for CD, PUSHD, and POPD commands and also fixed some bugs.
svn path=/trunk/; revision=40365
2009-04-05 01:50:24 +00:00
Jeffrey Morlan c1ff41171d Make cmd able to (sort of) work without a console.
svn path=/trunk/; revision=40289
2009-03-29 19:17:45 +00:00
Jeffrey Morlan ad25b56ea8 Make command parsing in DoCommand/Execute more compatible with Windows
svn path=/trunk/; revision=40280
2009-03-29 05:13:35 +00:00
Jeffrey Morlan db8815a497 - Implement CMD /D, /Q, and /R switches
- Do %envvar% expansions in CMD /C or /K commands
- Make SETLOCAL recognize ENABLEEXTENSIONS and DISABLEEXTENSIONS, although it doesn't do anything yet
- Make VERIFY set the errorlevel (documented in SETLOCAL /?). Also make it recognize when ON/OFF is followed by space
- Make ECHOSERR actually print to stderr, not stdout
- Make echoed display of ( ... ) blocks look nicer (Bug 4022)
- Fix some other minor display bugs

svn path=/trunk/; revision=40244
2009-03-26 01:14:25 +00:00
Jeffrey Morlan 2895b48a31 Implement all remaining switches for the START command.
svn path=/trunk/; revision=40198
2009-03-23 23:52:50 +00:00
Jeffrey Morlan e518029091 Make START command able to open non-executable files/directories/URLs using ShellExecute. (Bug 4055)
svn path=/trunk/; revision=40169
2009-03-22 01:51:29 +00:00
Jeffrey Morlan a98a143a48 - Make MEMORY command use GlobalMemoryStatusEx if available, so it can show values >= 4GB.
- Fix overflow bug in FREE command that caused values >= 4GB to wrap around.
- A little simplification of ConvertULargeInteger function

svn path=/trunk/; revision=40094
2009-03-18 18:11:19 +00:00
Jeffrey Morlan ef4415728b - Implement MKLINK command.
- Remove unused library shell32 from cmd.rbuild.

svn path=/trunk/; revision=40082
2009-03-17 22:27:33 +00:00
Jeffrey Morlan 34afc06d0a Implement ASSOC command (Bug 4275). Patch by Lee C. Baker <lee at leecbaker.com>.
svn path=/trunk/; revision=40062
2009-03-16 18:18:26 +00:00
Jeffrey Morlan 6f8ec7004e Fixed output of various date/time stuff ($D and $T in prompt, %DATE% and %TIME% variables, DATE /T and TIME /T commands) to be more compatible with Windows.
svn path=/trunk/; revision=40050
2009-03-16 00:44:08 +00:00
Jeffrey Morlan 4ef352817a In a 'Bad command or filename' error, print the name of the non-existent program, so getting the error from a batch file isn't so mysterious.
svn path=/trunk/; revision=39998
2009-03-13 01:26:08 +00:00
Jeffrey Morlan 8c83602d51 In a pipeline ("prog1 | prog2") run all programs simultaneously, using a real pipe instead of a temporary file. Output from RosBE "make" is now visible immediately instead of having to wait for it to complete.
svn path=/trunk/; revision=39991
2009-03-12 22:04:59 +00:00
Jeffrey Morlan eb94cff07d add ConPrintf and ConPrintfPaging prototypes to cmd.h
svn path=/trunk/; revision=39911
2009-03-08 19:21:07 +00:00
Jeffrey Morlan fff257c059 Implement SETLOCAL and ENDLOCAL commands. Make delayed expansion optional (disabled by default, enabled by CMD /V switch or with SETLOCAL)
svn path=/trunk/; revision=39892
2009-03-06 18:05:45 +00:00
Jeffrey Morlan 39d2af2432 Make CALL command do another round of %-variable substitutions.
svn path=/trunk/; revision=39879
2009-03-05 05:10:10 +00:00
Jeffrey Morlan 516e7fa09c Rework batch-file processing so that 'call file.bat' doesn't return until the file has finished, allowing constructs like 'call file.bat & somethingelse' to work properly.
svn path=/trunk/; revision=39858
2009-03-03 20:06:54 +00:00
Jeffrey Morlan 484ee2fa7e Separate batch file contexts and FOR contexts into two different structs, since they don't actually have anything in common any more
svn path=/trunk/; revision=39846
2009-03-02 19:08:25 +00:00
Jeffrey Morlan b18a547c1b Implement complete support for FOR command (including /D, /F, /L, and /R switches). cmd is now close to being able to run RosBE 1.3's initialization without errors.
svn path=/trunk/; revision=39742
2009-02-24 20:29:18 +00:00
Jeffrey Morlan 9b0334da19 Don't expand FOR variables until execution time, so that special characters in them won't cause unwanted syntactic effects.
For example, "for %a in (^>) do echo %a" should just echo the greater than sign.

svn path=/trunk/; revision=39611
2009-02-15 18:18:16 +00:00
Jeffrey Morlan 122c236111 Make delayed environment-variable expansions actually be delayed.
svn path=/trunk/; revision=39597
2009-02-14 01:13:17 +00:00
Jeffrey Morlan 2429c7df65 Don't treat a slash as the beginning of a new argument for the MOVE command (Bug 4013). Patch by Víctor Martínez Calvo <vicmarcal at hotmail.com>.
svn path=/trunk/; revision=38811
2009-01-17 12:55:46 +00:00
Jeffrey Morlan 781ae61f03 - Make IF command a special form; necessary to make nested multi-line IF blocks work properly
- Implement IF /I option, IF CMDEXTVERSION, and generic comparisons (EQU etc)
- Make IF ERRORLEVEL return true if the errorlevel is greater than the number
- Remove hacked support for multi-line IF blocks from batch.c

svn path=/trunk/; revision=38280
2008-12-22 22:34:51 +00:00
Jeffrey Morlan c49ed3a82c Remove the "LPTSTR cmd" argument to internal commands; there's no need for a command to be told its own name. It was only used in two places:
- a hack in cmd_mkdir that was already obsolete a decade ago
- to distinguish "echo" from "echo.", but that is the wrong way to implement this anyway. There's nothing particularly special about the period, "echo" is just one of those commands that is lenient about where its parameters begin, and when it echos a line, the first character (usually a space, but in the case of "echo." a period) is skipped.

svn path=/trunk/; revision=35647
2008-08-25 23:22:03 +00:00
Jeffrey Morlan 8b52a8e50a - Extract the line-reading code in ProcessInput to a separate function (ReadLine) that the parser can call. Now line continuations (using ^ at the end of a line) and multi-line parenthesized blocks work.
- ReadBatchLine: Don't strip the trailing \n, the parser needs it. Remove handling of :labels and @quiet commands, now done by the parser.
- ReadCommand: Add a \n to the line. Move PrintPrompt call out, since the prompt shouldn't be printed for additional lines read in a command beyond the first.

svn path=/trunk/; revision=35530
2008-08-22 14:37:11 +00:00
Jeffrey Morlan 4cdc27c1a2 - Begin writing a real parser for cmd. &, &&, ||, and () are implemented. The parenthesized blocks aren't too useful yet as the parser can't read additional lines; doing this will require some restructuring in cmd.c.
- Remove ^-removing hacks in echo and set.

svn path=/trunk/; revision=35514
2008-08-21 20:18:35 +00:00
Jeffrey Morlan 07912f2b23 - Implement X>&Y redirections. Hold redirections in a linked list structure, because order matters (>x 2>&1 is not the same as 2>&1 >x). Allow redirection of any handle number from 0 to 9.
- Allow quotes around the redirection file name.
- Batch: Fix buffer overflow bug (incorrect size for bc->BatchFilePath)

svn path=/trunk/; revision=35508
2008-08-21 15:33:59 +00:00
Jeffrey Morlan 198d88a60b - In cmd, add ConOutResPrintf and ConErrResPrintf functions for printf-ing from a resource string; use it to shorten several instances of LoadString+Con*Printf.
- Also change FilePromptYN and FilePromptYNA to take a resource ID. Remove varargs code which nobody used (and didn't actually work anyway)

svn path=/trunk/; revision=34816
2008-07-26 22:49:49 +00:00
Hervé Poussineau 2f9c333ded cmd: replace static traces by dynamic ones
svn path=/trunk/; revision=33533
2008-05-15 20:02:05 +00:00
Christoph von Wittich 775daf6fd1 rewrote alias handling in cmd for doskey compatibility
implemented AddConsoleAliasA, GetConsoleAliasesLengthA, GetConsoleAliasesLengthW
halfplemented: AddConsoleAliasW, GetConsoleAliasW, GetConsoleAliasesW

svn path=/trunk/; revision=32093
2008-02-02 21:06:53 +00:00
Christoph von Wittich cf39f6646d fix a bug in goto
a stubs for setlocal and endlocal (our default is delayed expansion)

svn path=/trunk/; revision=32073
2008-02-01 09:49:58 +00:00
Hervé Poussineau ae56de4440 Moved shared define to header file
Patch by Marc Piulachs, marc (dot) piulachs (at) codexchange.net
See issue #2700 for more details.

svn path=/trunk/; revision=29279
2007-09-28 12:17:19 +00:00
Hervé Poussineau b62929a83a Added history possibilities to right key
See issue #2248 for more details.

svn path=/trunk/; revision=29271
2007-09-28 08:51:04 +00:00
Aleksey Bragin 815cfb4aa2 Samuel Erdtman <samuel@erdtman.se>
- Implement 'replace' command in cmd.
- TODO: Update all translations with the new text strings for replace command.

svn path=/trunk/; revision=29240
2007-09-27 08:35:08 +00:00
Thomas Bluemel 4f2a8ebce4 Fix compiling rostests
svn path=/trunk/; revision=28096
2007-08-02 06:59:36 +00:00
Thomas Bluemel df91a99233 - Add code to detect buffer overflows and buffer underflows on memory operations. This code is only enabled if _DEBUG is defined.
- Change all calls to malloc, realloc and free to cmd_alloc, cmd_realloc and cmd_free

svn path=/trunk/; revision=28065
2007-08-01 10:17:13 +00:00
Colin Finck 32d235b53d Fix cmd build, when compilation units are turned off
svn path=/trunk/; revision=27748
2007-07-20 13:08:25 +00:00
Eric Kohl e0364c78da Remove outdated email addresses.
svn path=/trunk/; revision=26648
2007-05-05 11:32:25 +00:00
Ged Murphy a5c746a592 move explorer and cmd. Add a few .rbuild files
svn path=/trunk/; revision=21019
2006-02-16 23:23:37 +00:00