Eric Pouech
bf9a465e95
cmd: Implement semantic for chaining in ||, | and && operators.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-28 12:17:26 +02:00
Eric Pouech
7ccc169570
cmd: Add success/failure return code tests for CALL command.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-28 12:17:22 +02:00
Eric Pouech
6c39db0ca0
cmd: Migrate IF/FOR instructions inside CMD_NODE.
...
Basically:
- IF and FOR command parsing in integrated into node_builder,
- CMD_NODE is no longer degenerated (and no longer use
NULL CMD_COMMAND to mark end of block)
- lexer evolves to delegate a bunch of things to node_builder
(esp. command nesting...)
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53190
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50132
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44063
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-27 22:06:12 +02:00
Eric Pouech
6ad88c5512
cmd: Fix a couple of expansions issues.
...
Fix several incorrect behaviors that (partly) compensate each others:
- when replacing %XXX% by %YYY%, advance current position after the copied
%YYY% (otherwise it will expand %YYY% in same run),
- don't parse the command in run_program(),
- always expand full content in CALL command.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-26 16:54:40 +02:00
Eric Pouech
560521c14b
cmd: Add more tests about CALL and variable expansion.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-26 16:54:40 +02:00
Eric Pouech
fc4b9c645a
cmd: Fix a couple of issues wrt. variable expansion.
...
Ensure expansion at parse time is only done once.
Simply handleExpansion() code.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-24 13:24:05 +02:00
Eric Pouech
01d0027739
cmd/tests: Add tests for delayed substitution in IF command.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-21 22:59:40 +02:00
Eric Pouech
f98077591f
cmd: Fix delayed expansion in FOR loop on file sets.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-20 23:03:26 +02:00
Eric Pouech
6d6fee9dda
cmd: Fix delay expansion in FOR loop for filesets.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-19 11:38:10 +02:00
Eric Pouech
2e2a3f4539
cmd: Split parsing from executing FOR loops for filesets (/F).
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-19 11:38:09 +02:00
Eric Pouech
53f7a59992
cmd: Fix delay expansion in FOR /L loops.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-19 11:38:07 +02:00
Eric Pouech
2b51e5aca0
cmd: Enable '%0' through '%9' as valid FOR loop variables.
...
Note: there are many other letters than can be used as variable names.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-17 21:49:57 +02:00
Eric Pouech
85ca94be7c
cmd: Add more tests about FOR loops.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-17 21:49:50 +02:00
Eric Pouech
5388414923
cmd: Let errorlevel be a signed integer.
...
Manual testing show that native reports errorlevel as a signed
entity.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-06-04 22:22:01 +02:00
Eric Pouech
6f0e9e5e4e
cmd/tests: Test success/failure of commands.
...
The || and && operators to chain commands rely on the LHS command
to be successful (or unsucessful) to decide upon launching the RHS
command.
Unfortunately, success/failure is not always when errorlevel is
0 (non zero).
Some exmaples:
- if a redirection fails (eg. appending to a non existing file),
the command (builtin/external) is always unsuccessful (and the
error level is untouched,
- external command (when redirection is ok) is succesful when
program exit code is zero,
- ditto for a call to a label inside the batch file, with
the 'exit /b' parameter,
- it's way more complicated for builtins. Eg 'type' is unsuccessful
on a non existing file, while 'dir' (on the same unexisting file)
succeeds.
So start adding some tests about success / failure of some commands.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-05-07 22:49:45 +02:00
Eric Pouech
289c49ee21
cmd/tests: Test calling batch files named as builtin commands.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-05-07 22:49:45 +02:00
Eric Pouech
8bbd48bfd8
cmd/tests: Test delayed expansion with spaces in IF and FOR.
...
Based on a patch by Alex Henrie.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-05-07 22:49:45 +02:00
Eric Pouech
232f282585
cmd/tests: Test nested loop variables expansion.
...
Based on a patch by Dimitry Sokolov.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-05-07 22:49:45 +02:00
Eric Pouech
14bdf6e725
cmd/tests: Test using %%0-%%9 as loop variables.
...
Based on a test case from Dimitry Sokolov.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-05-07 22:49:45 +02:00
Eric Pouech
7f60584a90
cmd: Fix substring expansion for 'magic' variables.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56498
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-04-01 09:08:56 +02:00
Eric Pouech
b868d82391
cmd: Add test for substring handling in 'magic' variable expansion.
...
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-04-01 09:08:49 +02:00
Bernhard Übelacker
c418771a43
cmd: Avoid execution if block misses closing brackets.
2024-02-12 23:02:02 +01:00
Bernhard Übelacker
d7edf3e651
cmd: Handle lines with just spaces in bracket blocks.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51599
2024-02-12 23:02:02 +01:00
Alexandre Julliard
7ccb5df0fc
makefiles: Always use the global SOURCES variable for .rc files.
2023-11-01 22:43:56 +01:00
Alex Henrie
8f28294434
cmd: Reset ignoreBracket when moving to the next line.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55528
2023-10-09 11:40:34 +02:00
Akihiro Sagawa
ae8b7109f0
cmd: Always outputs leading zeros when listing file time information.
2023-09-26 21:35:21 +02:00
Akihiro Sagawa
2188e11e78
cmd/tests: Test file time stamp format.
2023-09-26 21:35:21 +02:00
Akihiro Sagawa
6800ab403e
cmd/tests: Add dir built-in command test.
2023-09-26 21:35:21 +02:00
Alex Henrie
859d5e68dd
cmd: Handle if exist
with an empty string argument.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55505
2023-09-04 20:41:54 +02:00
Dmitry Sokolov
7e4715149a
cmd: Fixed var substring in 'enableDelayedExpansion' mode.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55402
2023-08-25 22:52:42 +02:00
Alex Henrie
eba7092f0a
cmd: Allow numbered redirects at the beginning of a line.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55124
2023-07-05 21:08:33 +02:00
Maarten De Braekeleer
5e2f9996ba
cmd: Fix 'if exist' with a directory/ as a parameter.
...
'if exists' takes a parameter which can be directory, directory/,
directory/. directory\ or directory\. for example, and should equate
to true if the directory exists. The syntax directory\ is explicitly
rejected by FindFirstFile and hence was not working - look for this
specific case, and if found append a '.'.
Follow-up commit of bc9d68bcbe
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55130#add_comment
2023-06-26 16:44:17 +02:00
Liam Middlebrook
9aee47f7f6
cmd/tests: Add tests for PATH separator.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55097
Signed-off-by: Liam Middlebrook <lmiddlebrook@nvidia.com>
2023-06-21 18:25:38 +02:00
Arkadiusz Hiler
92e4cad8e0
cmd/tests: Make sure for /f doesn't loop infinitely on NULs.
2022-11-10 09:48:30 +01:00
Francois Gouget
be11845852
cmd: Fix the spelling of a batch file comment.
...
Signed-off-by: Francois Gouget <fgouget@free.fr>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-24 09:53:59 +01:00
Eric Pouech
ec0e9b3b94
cmd/tests: Enable compilation with long types.
...
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-17 09:07:07 +01:00
Alexandre Julliard
f0cd33c69e
include: Add support for defining Win32 types as 'long' where possible.
...
Add -DWINE_NO_LONG_TYPES to modules that still have compilation
warnings with long types.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-27 20:38:22 +01:00
Eric Pouech
1d178982ae
cmd/tests: Test paths that exceed MAX_PATH.
...
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-25 20:50:50 +01:00
Bernhard Übelacker
36cc3d4c9c
cmd/tests: Add test for attrib without parameter.
...
Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-08 20:49:19 +02:00
Roman Pišl
2d6b0b67d9
cmd: Fix handling of brackets in if-set expressions on a single line.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50642
Signed-off-by: Roman Pišl <rpisl@seznam.cz>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-10 20:07:24 +01:00
Roman Pišl
6809e0599e
cmd: Fix handling of nested if-for expressions on a single line.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50641
Signed-off-by: Roman Pišl <rpisl@seznam.cz>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-10 20:07:00 +01:00
Aaron Hill
8e54cad6a1
cmd: Set errorlevel to 0 when 'call' is invoked with an empty string.
...
Previously, invoking 'call' with an empty string would leave errorlevel
unchanged. Reset errorlevel to 0 to match the behavior of
the Windows 'cmd.exe'.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49982
Signed-off-by: Aaron Hill <aa1ronham@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-10-15 20:53:44 +02:00
Myah Caron
81fe7a2165
cmd.exe: Fix /Y flag for move builtin.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48397
Signed-off-by: Myah Caron <qsniyg@protonmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-09-11 16:57:42 +02:00
Francesco Noferi
fc1bb9aff5
cmd.exe: Fix parsing of && between quotes.
...
Signed-off-by: Francesco Noferi <lolisamurai@tfwno.gf>
Signed-off-by: Myah Caron <qsniyg@protonmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-09-11 16:57:42 +02:00
Bernhard Übelacker
c358de84c8
cmd/tests: Test that the if command is not influenced by a previous one.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47770
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48738
Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-04 12:55:13 +02:00
Zebediah Figura
2e45fdb194
cmd: Ignore quotes when parsing command line parameters.
...
This fixes a hang in the WinTV 8.5 installer.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-27 11:32:07 +02:00
Bernhard Übelacker
f238e846e7
cmd.exe: Change parsing of the if command to avoid parsing the operators.
...
Found while trying to look into bug 44236.
A batch script is executed containing a line like this:
if (%1)==(p) start /W " " "%SFDIR%WSFplot" wr2300.t35 3
This returns an error like this:
Syntax error
Can't recognize 'p' as an internal or external command, or batch script.
It looks like native does handle the brackets differently when contained
inside the condition part of the if command.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44338
Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-23 22:12:09 +02:00
Bernhard belacker
4684e1a9c6
cmd.exe: Command type with multiple files should print filenames to stderr.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46983
Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-21 20:04:40 +02:00
Alexander Coffin
fc358a8275
cmd/tests: Add some tests for "choice".
...
Signed-off-by: Alexander Coffin <alexcoffin1999@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-26 15:34:11 +01:00
Alexandre Julliard
0e33105abb
cmd/tests: Fix test failures on latest Windows 10.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-11 16:29:14 +01:00