Commit graph

792 commits

Author SHA1 Message Date
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
Eric Pouech 91cce00dba cmd: Better handle ctrl-c events.
cmd shouldn't terminate itself when user hits ctrl-c.
cmd should terminate the currently running CUI child it
waits for upon ctrl-c.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-09-06 12:05:49 +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
Akihiro Sagawa 322c175cf0 cmd: DIR command outputs free space for the path.
When the path contains a mountpoint on Unix or a junction point to
another drive on Windows, cmd.exe should show free space for the
path instead of the root of the drive.
2023-08-24 16:44:26 +02:00
Akihiro Sagawa 91de94ab99 cmd: Use towlower()/towupper() for WCHARs.
Found with Coccinelle.
2023-08-24 16:44:26 +02:00
Alex Henrie c27f8f72d1 cmd: Introduce an option_equals helper for WCMD_parse_forf_options. 2023-08-17 10:40:37 +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 0911d462f9 cmd: Fix empty strings between PATH separators.
Previously if an empty string was encountered while parsing out PATH,
cmd.exe would ignore the rest of the PATH entirely.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55097
Signed-off-by: Liam Middlebrook <lmiddlebrook@nvidia.com>
2023-06-21 18:25:48 +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
Alex Henrie 5792785879 cmd: Use standard C functions for memory allocation. 2022-12-09 17:52:25 +01:00
Eric Pouech f2ca35bd80 cmd: Use OEM code page when reading a file.
Calling GetConsoleCP() when ReadConsoleW() fails (potentially indicating
that cmd.exe's instance isn't attached to a console) makes no sense.

In details, since GetConsoleCP() returns 0 when not attached to a console
to indicate error, we're in fact using CP_ACP.

So fallback explicitely to OEM CP (which is the default for CUI programs).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-25 18:09:57 +01:00
Eric Pouech 8f1febc430 cmd: Don't write outside of variable array.
GCC 12.2 rightfully complains about an out-of-founds array access.
This can possibly happen for unsupported variable names.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-14 13:13:02 +01:00
Arkadiusz Hiler 92e4cad8e0 cmd/tests: Make sure for /f doesn't loop infinitely on NULs. 2022-11-10 09:48:30 +01:00
Eric Pouech e1c37c21da cmd: Use CRT file I/O function inside 'for /F' handling.
This allows:
- to mimic native behavior when a stray '\0' is present in file
  (in 'FOR /F' execution, it's interpreted as an EOF marker)
  (prevents an infinite loop)
- supports (with /USEBACKQ) unicode output (if BOM is present)

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53386
2022-11-10 09:48:23 +01:00
Alex Henrie 212e319dce cmd: Use the wcsrev function instead of reimplementing it. 2022-11-04 19:23:55 +01:00
Alex Henrie 6ee8f819cf cmd: Remove inapplicable comment from WCMD_getfileowner. 2022-11-04 19:23:55 +01:00
Eric Pouech 7de36f8e98 cmd: Skip too long paths.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 22:02:56 +02:00
Eric Pouech 69f9480cde cmd: Test that read is successful before using its result.
There are cases where the read can fail (not attached to a console,
input stream mapped to /dev/null...)

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 22:02:50 +02: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
Eric Pouech 7f9b9df04f cmd: 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
Eric Pouech 23817bb8d9 cmd: Bail out when full path name exceeds MAX_PATH.
This mimics native behavior and prevents buffer overflows.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-25 20:50:49 +01:00
Eric Pouech 535da77552 cmd: Don't crash on 'if exist' without parameter.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51598
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-20 17:51:54 +01:00
Alexandre Julliard a8a250cdbc cmd: Use the standard va_list instead of __ms_va_list.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-25 11:00:27 +02:00
Zhiyi Zhang efd98caef1 cmd: Pass size in bytes to RegQueryValueExW().
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-20 11:22:26 +02:00
Alexandre Julliard 088a787a2c makefiles: Make -mno-cygwin the default.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-20 22:45:48 +02:00
Bernhard Übelacker 810de9d1a7 cmd: Load start.exe from the system directory.
Fixes cmd test in pure 64-bit wine.

Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-09 22:30:45 +02: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
Alex Henrie 14bbccf756 cmd: Fix capitalization of WCMD_ReadFile in comment.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-06 14:50:28 +02:00
Florian Eder 617d14bc12 cmd: Do not change errorlevel when setting environment variables.
Changes CMD to set its errorlevel to 0 only when the value of an environment variable
is set in in non-interactive / batch mode, retains the previous value otherwise.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47791
Signed-off-by: Florian Eder <others.meder@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-18 21:08:03 +02:00
Gijs Vermeulen 0bf71745f0 cmd: Use terminated strings.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48486
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-15 17:41:40 +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
Jacek Caban 2ecb871310 cmd: Don't use WCMD_is_console_handle.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-12-01 19:50:20 +01:00
Michael Stefaniuc 40ce3c5b60 cmd: Use wide-char string literals.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-30 21:36:12 +01:00
Michael Stefaniuc a158bf7e9c cmd: Use wide-char string literals in builtins.c.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-30 21:36:12 +01:00
Michael Stefaniuc 9fcb2b097c cmd: Inline some simple extern WCHAR strings.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-30 21:36:12 +01:00
Michael Stefaniuc 77fc01d39d cmd: Avoid casting a const away.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-30 21:36:12 +01:00
Damjan Jovanovic abe848f05f cmd.exe: Increase size of WCMD_HandleTildeModifiers() buffers to MAXSTRING.
Some buffers in WCMD_HandleTildeModifiers() are only of size MAX_PATH,
even though they handle strings that aren't necessarily
filenames. When changed to have size MAXSTRING, a stack overflow crash
with strings of size MAX_PATH stops happening.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42731
Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-17 21:16:43 +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 d1790c984b cmd.exe: Don't prompt for move when non-interactive.
Based on a patch by Francesco Noferi.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48396
Signed-off-by: Myah Caron <qsniyg@protonmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-09-11 16:57:42 +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