Why do people exit /b instead of goto :eof
Moderator: DosItHelp
Why do people exit /b instead of goto :eof
I presume its faster
Re: Why do people exit /b instead of goto :eof
I have no idea about performance. I've always assumed it was a matter of personal preference.
I've always felt that exit /b looks more elegant. Goto :eof strikes me as kludgey or hackish, but I don't know of any compelling reason to use one over the other. I'm pretty sure goto :eof predates exit /b, so many people got used to using it before exit /b became available.
One advantage of exit /b is it allows you to set the errorlevel as in exit /b 23
Dave Benham
I've always felt that exit /b looks more elegant. Goto :eof strikes me as kludgey or hackish, but I don't know of any compelling reason to use one over the other. I'm pretty sure goto :eof predates exit /b, so many people got used to using it before exit /b became available.
One advantage of exit /b is it allows you to set the errorlevel as in exit /b 23
Dave Benham
Re: Why do people exit /b instead of goto :eof
advantage ? Then I will have to start using it exit /b 0
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: Why do people exit /b instead of goto :eof
Same as dbenham said, but I don't care much for setting the errorlevel, except one trick.
First, if for some reason I need to reset the errorlevel to 0, use verify>nul. I didn't test the performance, but there's no way it's slower than cmd /c exit 0.
Second, a guy named carlos or something here posted some awesome tricks almost a year back.
You can easily convert any decimal to hexadecimal from 0 to FFFFFFFF by:
cmd /d /c exit 12345
echo Hex of 12345: %=exitcode%
First, if for some reason I need to reset the errorlevel to 0, use verify>nul. I didn't test the performance, but there's no way it's slower than cmd /c exit 0.
Second, a guy named carlos or something here posted some awesome tricks almost a year back.
You can easily convert any decimal to hexadecimal from 0 to FFFFFFFF by:
cmd /d /c exit 12345
echo Hex of 12345: %=exitcode%