File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -43,3 +43,34 @@ goto :eof
4343 )
4444 endlocal & set " %result_var% = %win_major_ver% "
4545goto :eof
46+
47+
48+ :print < MESSAGE>
49+ :: outputs the message to the console without trailing new line characters
50+ echo| set /p=" %~1 "
51+ goto :eof
52+
53+
54+ :capture < CMD> [< RESULT_VAR> ] [< LINE_SEPARATOR> ]
55+ :: captures the output of a command in a variable
56+ setlocal EnableDelayedExpansion
57+ set cmd = %~1
58+ set result_var = %~2
59+ set line_separator = %~3
60+ if not defined line_separator (
61+ set line_separator = ^ & echo .
62+ )
63+ set stdout =
64+ for /F " delims=" %%f in ('%cmd% ') do (
65+ if defined stdout (
66+ set " stdout = !stdout!!line_separator! %%f "
67+ ) else (
68+ set " stdout = %%f "
69+ )
70+ )
71+ if not defined result_var (
72+ echo %stdout%
73+ exit /B 0
74+ )
75+ endlocal & set " %result_var% = %stdout% "
76+ goto :eof
You can’t perform that action at this time.
0 commit comments