1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 11:56:11 +00:00
Commit Graph

782 Commits

Author SHA1 Message Date
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
Alexandre Julliard
88c34b39ed cmd: FormatMessage() now reports ERROR_NO_WORK_DONE error for empty string.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-13 22:07:31 +02:00
Gabriel Ivăncescu
a19a770f96 cmd.exe: Don't treat explicit paths as a PATH search list.
For example, the explicit path "C:\some;path" is currently treated as if
the PATH environment variable is "C:\some;path" which is obviously wrong,
and searches for the directories "C:\some" and "path".

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-06 19:53:01 +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
Bernhard Übelacker
b1e91a36a7 cmd: Fix crash in if condition parsing.
Regression introduced in f238e846e7.

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
Zebediah Figura
16c938cb66 cmd: Fix the spelling of "tilde".
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-27 11:32:05 +02:00
Zebediah Figura
60b3db6b98 cmd: Use _wsplitpath() from msvcrt.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-27 11:32:03 +02:00
Brendan Shanks
e8f16fcbcc cmd: Use RtlGetVersion to fix displayed Windows version on Win8.1 or 10 prefix.
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-16 22:10:04 +02:00
Gijs Vermeulen
e737aafa8e cmd: Use wide character string literals in directory.c.
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-03-25 19:26:17 +01:00
Gijs Vermeulen
5fd548fc9b cmd: Use wide character string literals in batch.c.
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-03-25 19:25:47 +01:00