Commit Graph

265 Commits (e6c6874ec323c9d657bfa9b69e04cb2a8cc1a522)

Author SHA1 Message Date
Jason Edmeades 6cb520476a cmd: Fix statements after 'else' inside for loops.
When inside a for loop, an 'if' statement is processed and the true part
taken. Once all the commands in the true are processed, the else part is
parsed, and a flag set to skip all commands in the else part. Unfortunately
this flag is left on even when the if statement ends, meaning subsequent
commands are also skipped.

Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-16 09:19:20 +02:00
Jason Edmeades 4030a95209 cmd: Handle special case tokens=* in for /f.
for /f allows a special syntax of tokens=* (rather than tokens=1* for example)
which just means put the whole line into the next variable). Note the handling of
the 'next variable' was wrong in the case of it being 'A' or 'a' as the wrap
calculation was wrong, but this only affected using this new syntax.

Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-16 09:18:23 +02:00
Jason Edmeades f634fe15db cmd: Fix handle leak in if exists.
Fixes regression in f53d57c854.

Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-16 09:16:48 +02:00
Jason Edmeades ab46a89c3b cmd: Fix issue in WCMD_assoc highlighted by valgrind.
In an error condition, the wrong variable was being used for an insert,
resulting in a read from uninitialized data. This could be triggered for
example by 'ftype jason=', and the error message should have included
jason but instead was just ''.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38849
Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-05 11:38:58 +02:00
Jason Edmeades 254dc78c2c cmd: Call and goto finds the next matching label.
A call or a goto will find the next matching label not the first one in the
file. This means it could be later in the file or it could be earlier in the
file, so make goto (which 'call' also uses) first scan from current file
position to the end of the file, and subsequently from the start of the file
to the wrap point.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42823
Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-05 11:38:13 +02:00
Jason Edmeades 15215bd071 cmd: Fix subdirectory prefix in for loops.
A for loop can be working through a wildcarded subdirectory, but when
processing the first file in the subdirectory, it stores the prefix in
a static variable which gets overwritten during the 'for' body
processing.

Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-06-25 21:44:48 +02:00
Jason Edmeades f53d57c854 cmd: Add support for wildcards in if exist.
Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-06-25 21:44:48 +02:00
Bernhard Übelacker f95b85a856 cmd: Avoid having first parameter to start.exe ignored.
Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-04-27 17:07:48 +02:00
Fabian Maurer e62000c5c0 cmd.exe: Parse parameters in "FOR /F" properly.
We must not remove the quotes from parameters, or strings like
"param=value" will get parsed incorrectly.

Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-02-07 22:22:53 +01:00
Andrey Gusev b84fb5974f cmd: Remove redundant comparison.
Signed-off-by: Andrey Gusev <andrey.goosev@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-01-09 16:01:42 +01:00
Alistair Leslie-Hughes 21ade8538d cmd: Implement builtin mklink command.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-11-14 20:45:44 +01:00
Bas Weelinck 9baceabb88 cmd: Detect and handle start console title.
Signed-off-by: Bas Weelinck <bas.weelinck@gmail.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-17 22:21:12 +02:00
André Hentschel c9903aedcb cmd: Remove dead assignments (clang).
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-01-31 08:52:28 +01:00
Lauri Kenttä 21dd04670c cmd: Fix memory leak in WCMD_reduce.
Signed-off-by: Lauri Kenttä <lauri.kentta@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-19 20:33:15 +01:00
Lauri Kenttä 064508c0dd cmd: Fix copying when the dest is one of the sources.
"COPY a+b a" appends b to a.
"COPY a+b b" skips b from the sources.

Signed-off-by: Lauri Kenttä <lauri.kentta@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-06 18:57:12 +01:00
Lauri Kenttä 048a80ffe4 cmd: Compare handles to INVALID_HANDLE_VALUE, not NULL.
Signed-off-by: Lauri Kenttä <lauri.kentta@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-06 15:02:35 +01:00
Carlos Rafael Ramirez 55be713d76 cmd: When 'if' condition is not met, ignore the next commands in the list.
Signed-off-by: Carlos Rafael Ramirez <crramirez@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-11-01 20:32:56 +01:00
Francois Gouget 003fb4b139 cmd: Fix a spelling erro in a TRACE() message.
Signed-off-by: Francois Gouget <fgouget@free.fr>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-04-25 18:48:18 +09:00
Hugh McMaster 16cb9c4cb7 cmd: 'del' should set %errorlevel% to zero, not one, on error.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-17 22:56:40 +09:00
Hugh McMaster ca8b3843ab cmd: Set colour attributes when clearing the screen with 'cls'.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-16 17:51:25 +09:00
Frédéric Delanoy 23e7b5a6b0 cmd: Simplify boolean expressions (PVS-Studio).
Signed-off-by: Frédéric Delanoy <frederic.delanoy@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-10-14 12:51:17 +09:00
Thomas Faller 1d09a35878 cmd: Implement 'echo/'. 2015-08-19 08:39:26 +09:00
Andrey Gusev 5cdcd4493f Assorted spelling and typos fixes. 2015-08-18 15:00:13 +09:00
Thomas Faller 3cda870469 cmd: Fix invalid "else if" execution. 2015-06-25 13:56:40 +09:00
Thomas Faller 43dfe76376 cmd: Fix access of uninitialized memory. 2015-06-12 21:22:42 +09:00
Francois Gouget f505e6fb4a Assorted spelling fixes. 2015-03-19 21:54:14 +09:00
Michael Stefaniuc 232390e5b8 cmd: Remove duplicated if-check (PVS-Studio). 2014-11-27 11:43:22 +01:00
Alexandre Julliard 3d3c5ab400 cmd: Add a helper function to check if a path ends with a backslash. 2014-10-30 13:11:27 +09:00
Gerald Pfeifer 51d217e6df cmd: Remove fslashW. 2014-08-21 12:23:38 +02:00
Thomas Faber d4c4f0ab95 cmd: Do not omit mandatory argument to WriteFile. 2014-07-14 17:22:40 +02:00
Frédéric Delanoy 95ae71f3ab Assorted spelling/grammar fixes. 2014-07-01 13:09:13 +02:00
Frédéric Delanoy 0f2bed51bd Assorted spelling fixes. 2014-02-10 15:47:29 +01:00
Frédéric Delanoy e459131677 cmd: Use BOOL type where appropriate. 2013-10-17 10:45:05 +02:00
Marcus Meissner e85d3c7108 cmd: null terminate answer string (Coverity). 2013-07-10 10:53:14 +02:00
Jason Edmeades a5b1172e90 cmd: Fix 'for' expansion of wildcards when no args are supplied. 2013-06-05 11:45:23 +02:00
Jason Edmeades 56a33a8c55 cmd: set "var=value" ignores trailing characters. 2013-06-05 11:45:19 +02:00
Jason Edmeades dc4dd0cb97 cmd: Fix handling of redundant information on goto/labels. 2013-06-04 21:01:13 +02:00
Michael Stefaniuc 6899279bab cmd: Print the debug string instead of the pointer value. 2013-04-17 21:29:20 +02:00
Jason Edmeades 0b00b717b9 cmd: Add beginnings of support for delayed expansion. 2013-01-07 11:15:23 +01:00
Jason Edmeades 3735bf6af5 cmd: Avoid division by zero in set /a with %. 2013-01-07 11:14:24 +01:00
Francois Gouget f963f93964 Assorted spelling fixes. 2013-01-07 11:10:40 +01:00
Ann and Jason Edmeades 95279b87e4 cmd: Add set /a support. 2012-12-21 12:00:19 +01:00
Frédéric Delanoy 5188f08bf4 cmd: Remove dead assignments (clang). 2012-12-20 12:00:45 +01:00
Jason Edmeades d16f4e700b cmd: Add support for NUL in copy. 2012-11-20 11:53:15 +01:00
Jason Edmeades 47b35d5545 cmd: Add support for tokens= (for /f). 2012-11-20 11:46:40 +01:00
Jacek Caban 08c17ada57 cmd: Added HeapFree wrapper. 2012-11-16 11:40:36 +01:00
Jacek Caban c6d24089db cmd: Make allocation unfailable. 2012-11-15 21:21:53 +01:00
Jason Edmeades ae4571fb79 cmd: Fix for loops within for loops. 2012-11-06 16:02:41 +01:00
Frédéric Delanoy 5108b18940 cmd: Fix some leaks (coverity). 2012-11-01 15:54:40 +01:00
Frédéric Delanoy 1d3f679ef1 cmd: Avoid handle leaks (coverity). 2012-10-30 19:14:37 +01:00