Unappropriated errorlevel when built from command line

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
serge_t
Posts: 4
Joined: Mon 15 Apr 2013 08:03

Unappropriated errorlevel when built from command line

Post by serge_t » Mon 15 Apr 2013 08:14

Hello,

Building UniDAC 4.5.9 05-Sep-12 from sources (Delphi 7, Win XP SP3) produces unappropriated errorlevel > 0 when no errors occurred.

To check it create make2.bat in "Source\Delphi7"

Code: Select all

@echo off
call Make.bat
if errorlevel 1 (
  echo.Errors occurred 
) else (
  echo.OK
)
The problem may be in "popd" command. If you modify main "Source\make.bat" by adding exit 0 all is ok.

Code: Select all

:end
popd
rem Add this
exit /b 0

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Unappropriated errorlevel when built from command line

Post by AlexP » Mon 15 Apr 2013 10:02

hello,

Our bat file doesn't return errors, you can check this by adding the errorlevel check after the lilnes:

Code: Select all

:end
popd
rem Add
if errorlevel 1 (
  echo.Errors occurred 
) else (
  echo.OK
)
This behaviour is due to the cmd interpreter. This can be seen by creating a simple bat file with the following commands:

Code: Select all

@echo off
pushd
popd
and run it from your bat file

serge_t
Posts: 4
Joined: Mon 15 Apr 2013 08:03

Re: Unappropriated errorlevel when built from command line

Post by serge_t » Mon 15 Apr 2013 11:17

Please run it from your Make.bat located in Source\Delphi7 to see the problem:

Code: Select all

@echo off
rem **********************************************************************
rem *
rem * Unidac for Delphi 7
rem *
rem **********************************************************************

rem --- Win64 compatibility ---
if "%ProgramFiles(x86)%"=="" goto DoWin32
set PROGRAMFILES=%ProgramFiles(x86)%
:DoWin32

set IdeDir="%PROGRAMFILES%\Borland\Delphi7
call ..\Make.bat Delphi 7
if errorlevel 1 (
  echo.Errors occurred
) else (
  echo.OK
)
What exactly is the option you mean?
We used default options set up by Windows only.
And simple "exit /b 0" prevent yours BATs from getting any of this kind of problems.

This problem blocked us including UniDAC compilation by makefile.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Unappropriated errorlevel when built from command line

Post by AlexP » Wed 17 Apr 2013 10:44

Hello,

There is no reason to reset errorlevel, since we check this variable after each operation in our BAT file, and if there is any error, script execution will be terminated, an error message will be shown, and the script will wait for pressing any button. Therefore, if you invoke our file from your own one, there is no need to check errorlevel after execution of our script.

serge_t
Posts: 4
Joined: Mon 15 Apr 2013 08:03

Re: Unappropriated errorlevel when built from command line

Post by serge_t » Wed 17 Apr 2013 11:00

AlexP wrote:There is no reason to reset errorlevel, since we check this variable after each operation in our BAT file, and if there is any error, script execution will be terminated, an error message will be shown, and the script will wait for pressing any button.
So, your script cannot be included in automatic build system (continuous integration) because of waiting input in case of any error?
AlexP wrote:Therefore, if you invoke our file from your own one, there is no need to check errorlevel after execution of our script.
I'll be glad to believe what your script is never failed. However, the normal practice is to assure it.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Unappropriated errorlevel when built from command line

Post by AlexP » Wed 17 Apr 2013 12:41

Hello,

We didn't provide for the use of our script from other scripts or applications, the script is designed to be used by end-user and to simplify package build. Therefore, on script execution error, the pause method is interrupted and invoked in order for the error reason to be seen. If you need to embed your script to yours, you can edit it by yourself in any way.

serge_t
Posts: 4
Joined: Mon 15 Apr 2013 08:03

Re: Unappropriated errorlevel when built from command line

Post by serge_t » Wed 17 Apr 2013 13:42

Ok, now it's clear.

Post Reply