Last active
August 29, 2015 14:21
-
-
Save maphew/7bd9f0af1914cc7839ba to your computer and use it in GitHub Desktop.
Print the command line to screen and then execute it. Useful when you want to have echo turned off everywhere else, and not speckle code with `echo on && {cmd line here} && @echo off`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: --- Run.bat --- | |
:: Echo the command line to screen and then execute it. | |
:: | |
:: Useful when you want to have echo turned off everywhere else, | |
:: and not speckle code with `echo on && {cmd line here} && @echo off` | |
if "%*"=="" goto :Usage | |
setlocal | |
echo === Run ================= | |
set _cmd=%* | |
echo %_cmd% | |
call %_cmd% | |
if not %errorlevel%==0 (echo. && echo *** Non-zero exit code: %errorlevel%) | |
echo ========================= | |
endlocal | |
goto :eof | |
:Usage | |
echo. | |
echo. Usage: %~n0 [command] {parameters} | |
echo. | |
goto :eof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
call :run [command -par1 -par2 in_thing out_thing] | |
goto :eof | |
:: --------------------------------------------------------------------------- | |
:run | |
:: Echo the command line to screen and then execute it. | |
:: | |
:: Useful when you want to have echo turned off everywhere else, | |
:: and not speckle code with `echo on && {cmd line here} && @echo off` | |
setlocal | |
set _cmd=%* | |
echo %_cmd% | |
%_cmd% | |
if not %errorlevel%==0 (echo. && echo *** Exit code: %errorlevel% && echo.) | |
endlocal | |
goto :eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment