[Bug 50132] New: Command line: Incorrect behaviors in FOR () and IF () blocks
WineHQ Bugzilla
wine-bugs at winehq.org
Fri Nov 13 16:48:00 CST 2020
https://bugs.winehq.org/show_bug.cgi?id=50132
Bug ID: 50132
Summary: Command line: Incorrect behaviors in FOR () and IF ()
blocks
Product: Wine
Version: 5.21
Hardware: x86-64
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: cmd
Assignee: wine-bugs at winehq.org
Reporter: Psycho-A at yandex.ru
Distribution: ---
The native CMD.exe contains many syntax and other errors related to the FOR and
IF commands processing inside of ()-blocks. This is very importans for apps
that require complex batch scripts on run. Let's begin.
Case 1:
-------
Different behavior when using brackets after "DO"
:: Returns ")" error:
for %%a in (*.txt) do if #==# (
echo File: "%%~a"
)
:: Works normal:
for %%a in (*.txt) do (if #==# (
echo File: "%%~a"
))
:: Works normal:
for %%a in (*.txt) do if #==# echo File: "%%~a"
In Windows CMD all three results works the same (returns ECHO text).
Case 2:
-------
Reading empty lines of text file if EOL=# specified
:: ECHO will return "" text here:
for /f "usebackq eol=: tokens=1" %%a in ("File.txt") do (
echo "%%~a"
)
Windows CMD skips empty lines anyway.
Case 3:
-------
Error behavior if an empty line with Space ot Tab is defined in body
:: Will return ")" error:
if #==# (
echo Some text
)
:: Just will show ECHO text:
if #==# (
echo Some text
)
Case 4:
-------
Not-expanding variables from parent cycle child one
:: Will show "%~m" in child cycles:
for %%f in (*.txt) do (
echo In parent cycle: "%%~f"
for %%x in ("%%~f") do (
echo In child cycle: "%%~x"
)
)
:: Will seek in "%~f" dir instead of "Folder1":
for %%f in ("Folder1") do (
for /r "%%~f" %%x in (*.txt) do (
echo "%%~x"
)
)
Windows CMD expands "%%f" in any child cycle's place.
Case 5:
-------
Error if no quotes in file/command condition
:: Returns "DO is not an application" error:
for /f %%a in (File.txt) do (
echo "%%~a"
)
:: Reads strings of File.txt:
for /f "usebackq" %%a in ("File.txt") do (
echo "%%~a"
)
Windows CMD reads file in both cases
("usebackq" uses to use quotes around filename).
This error appears only when target file not found.
Case 6:
-------
Using global ">" redirection after ()-body issue:
:: Will show ECHO text and create empty Test.bug
if #==# (
echo Text 1...
echo Text 2...
)> "Test.bug"
:: Will write Test.bug with echo text (normal case)
if #==# (
echo Text 1...> "Test.bug"
echo Text 2...> "Test.bug"
)
Windows CMD does the same as second in both cases.
Case 7:
-------
Incorrect IF() ELSE() processing if FOR() inside
:: Returns "ELSE is not an application" error:
if #==# (
echo IF condition.
for %%m in (*.txt) do (
echo FOR cycle.
)
) else (
echo ELSE condition.
)
:: Works normally:
if #==# (
echo IF condition.
) else (
echo ELSE condition.
)
Also ELSE works normal when IF condition is NOT equal.
Case 8:
-------
No processing file mask if it's quoted
:: Returns txt files that found:
for %%f in (*.txt) do (
echo "%%~f"
)
:: Returns nothing
for %%f in ("*.txt") do (echo "%%~f")
for %%f in ("Dir\*.txt") do (echo "%%~f")
The same is if FOR with /R key is used.
For now that's all I found.
Some of Wine 4.x bugs I knew seems to be fixed already.
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list