我正在遍历命令的结果,并将它们全部附加到!results!
该循环中的一个变量 ( ) 中。在循环结束时,如果结果不为空,则打印它们。我希望每个结果都出现在新行上。
setlocal EnableDelayedExpansion
set results=
set lf=^
for /f "delims=" %%a in ('call mvn dependency:analyze ^| findstr "WARNING"')
do ( set results=!results!!lf!%%a )
if not [!results!]==[] (
echo. ------------------------------------
echo. FOUND MATCHES
echo. ------------------------------------
echo. !results!
echo. ------------------------------------
echo. ------------------------------------
echo. && echo.
)
我正在尝试使用我在这里看到的新行批处理黑客,但它似乎在这种情况下不起作用。
我得到了什么
------------------------------------
FOUND MATCHES
------------------------------------
[WARNING] Used undeclared dependencies found: [WARNING] org.springframework:spring-jms:jar:3.0.5.RELEASE:compile [WARNING] org
.springframework:spring-beans:jar:3.0.5.RELEASE:compile [WARNING] xml-apis:xml-apis:jar:1.3.04:compile
------------------------------------
------------------------------------
我想要什么
------------------------------------
FOUND MATCHES
------------------------------------
[WARNING] Used undeclared dependencies found:
[WARNING] org.springframework:spring-jms:jar:3.0.5.RELEASE:compile
[WARNING] org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[WARNING] xml-apis:xml-apis:jar:1.3.04:compile
------------------------------------
------------------------------------