Edgewall Software
Modify

Opened 18 years ago

Last modified 17 years ago

#126 new enhancement

Add bitten environment variable to shell executed commands

Reported by: russell@… Owned by: cmlenz
Priority: trivial Milestone:
Component: Build slave Version: 0.5.3
Keywords: build environment Cc:
Operating System: BSD

Description

The method used to execute a system command ultimately boils down to a cmd /c on Windows. This launches a new process of cmd.exe, runs the specified application and then immediately exits.

The problem comes when you specify a batch (.bat) file to execute. To return a value from this you must use, for example exit 1. However if the batch file is run outside of the Bitten environment, in a normal windowed instance of cmd.exe, then this causes it to exit completely.

At first glance the solution would seem to be to use exit /b 1 (supported on windows 2000 & xp), this exits a batch file script with the return value and not the instance of cmd.exe, unfortunately in the Python/Bitten? system, this return value is only passed back as far as the calling process, which of course is immediately killed.

In summary: it seems impossible to pass a return value back from a directly called batch file on a Windows operating system.

We have fixed this by making Bitten add a 'flag' variable to the environment it creates the cmd.exe instance in. Therefore any applications/batch files running in this temporary environment know that they have been called as a result of a Bitten build recipe and can perform additional tasks if required.

In the example case, obviously it can choose which method to exit with, but as this might be useful in many other situations I'm proposing that it be implemented in the master source base.

api.py

        +++   os.environ['BITTEN_EXEC']="1"
        113   self.returncode = os.system(cmd)

Attachments (0)

Change History (1)

comment:1 Changed 18 years ago by anonymous

  • Priority changed from minor to trivial

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain cmlenz.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.