Monday, May 9, 2011

Line continuations and && in DOS

Notes to myself:

  • && works in DOS too (only do step 2 if step 1 succeeded)

  • Use ^ for line continuation

  • Use %ERRORLEVEL%, labels, and goto, for some primitive flow control.

Here's an example

@echo off

set basedir=Z:\path\to\dir

cd %basedir% && ^
hg fetch -R .\MRA && ^
hg fetch -R ".\Super common" && ^
hg fetch -R .\ServerKpf

goto answer%ERRORLEVEL%
echo hg fetch complete
komodo "%basedir%\ServerKpf\dev_util_nds_dev.kpf"
goto end
echo Program had return code 1
goto end

Multiple Commands in Single Line
DOS IF command

No comments: