[M3devel] rcc_upgradecm3.cmd

Jay K jay.krell at cornell.edu
Wed Nov 10 12:37:10 CET 2010


Randy, code like this:


pushd ..\..\..
if exist "bin\cm3.exe" if exist "pkg" set CM3_ROOT=%CD%& popd & goto FoundRoot


is almost exactly equivalent to:

if exist "..\..\..\bin\cm3.exe" if exist "..\..\..\pkg" set CM3_ROOT=..\..\..& popd & goto FoundRoot

the advantage of the second form is fewer intermediate side effects
  i.e. not cd'ing around to the various possible path, just using them more directly
the disadvantage of the second form is the ".." survive  and may be unsightly.
  But leaving ".." will work ok with very little exception.
The ".." can be removed via e.g.:

call :GetFullPath CM3_ROOT %CM3_ROOT%
goto :end_GetFullPath

:GetFullPath
set %1=%~f2
goto :eof
:end_GetFullPath

I believe that would also work.

There are other ways..
such as looping over all the possibilities and taking the first that works.

anyway..
 - Jay
 		 	   		  


More information about the M3devel mailing list