-
Bug
-
Resolution: Fixed
-
Low
-
5.3.7
-
None
-
Severity 3 - Minor
-
Summary
Some of Bitbucket's .bat files use the following form to check for errors:
if not errorlevel 0 …
The problem is that Windows actually treats errorlevel comparison as a greater-than-or-equal-to operation. In other words, in the presence of errorlevel 1, the test if not errorlevel 0 … will actually return false instead of true.
Steps to Reproduce
- Edit set-bitbucket-home.bat and comment out the value for BITBUCKET_HOME, eg.:
set-bitbucket-home.bat
rem set BITBUCKET_HOME=C:\\Atlassian\\ApplicationData\\Bitbucket
This will cause set-bitbucket-home.bat to return an error after it's called.
- Run <bitbucket-install>/bin/start-bitbucket.bat
Expected Results
When the following codepath runs in start-bitbucket.bat, it should exit immediately after set-bitbucket-home.bat returns errors:
call %BIN_DIR%\set-bitbucket-home.bat if not errorlevel 0 exit /b if "%1" == "/no-search" set NO_SEARCH=1 echo Starting Atlassian Bitbucket
In other words, the following error should be printed, and then the script should immediately exit without proceeding further:
c:\Atlassian\Bitbucket\5.2.2\bin>start-bitbucket.bat
Bitbucket doesn't know where to store its data. Configure the BITBUCKET_HOME
environment variable with the directory where Bitbucket should store its data.
Ensure the path to BITBUCKET_HOME does not contain spaces. BITBUCKET_HOME may
be configured in set-bitbucket-home.bat, if preferred, rather than exporting it
as an environment variable
Actual Results
start-bitbucket.bat does not exit and continues running, until the underlying problem causes another error to occur:
c:\Atlassian\Bitbucket\5.2.2\bin>start-bitbucket.bat Bitbucket doesn't know where to store its data. Configure the BITBUCKET_HOME environment variable with the directory where Bitbucket should store its data. Ensure the path to BITBUCKET_HOME does not contain spaces. BITBUCKET_HOME may be configured in set-bitbucket-home.bat, if preferred, rather than exporting it as an environment variable Starting Atlassian Bitbucket "_start-search.bat is not intended to be run directly. Run start-bitbucket.bat instead" "_start-webapp.bat is not intended to be run directly. Run start-bitbucket.bat instead" "To start the Bitbucket webapp without starting search, run start-bitbucket.bat /no-search"
Workaround
Substitute if not errorlevel 0 for if errorlevel 1, which returns true for all error levels greater than or equal to 1
[BSERV-10020] Errorlevel checking in windows .bat scripts returns false negatives
Fix Version/s | New: 5.4.0 [ 73619 ] | |
Affects Version/s | New: 5.3.7 [ 77792 ] |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Gathering Impact [ 12072 ] | New: Closed [ 6 ] |
Workflow | Original: Stash Workflow - Restricted [ 2419376 ] | New: JAC Bug Workflow v3 [ 3136826 ] |
Status | Original: Open [ 1 ] | New: Gathering Impact [ 12072 ] |
Symptom Severity | Original: Minor [ 14432 ] | New: Severity 3 - Minor [ 15832 ] |
Assignee | New: Dave Chevell [ dchevell ] |
Status | Original: Needs Triage [ 10030 ] | New: Open [ 1 ] |
Component/s | New: Installer - Windows [ 28790 ] |
Description |
Original:
h3. Summary
Some of Bitbucket's .bat files use the following form to check for errors: {{if not errorlevel 0 …}} The problem is that Windows actually treats errorlevel comparison as a greater-than-or-equal-to operation. In other words, in the presence of errorlevel 1, the test {{if not errorlevel 0 …}} will actually return *false* instead of true. h3. Steps to Reproduce # Edit *set-bitbucket-home.bat* and comment out the value for {{BITBUCKET_HOME}}, eg.: {code:title=set-bitbucket-home.bat} rem set BITBUCKET_HOME=C:\\Atlassian\\ApplicationData\\Bitbucket {code}This will cause *set-bitbucket-home.bat* to return an error after it's called. # Run *<bitbucket-install>/bin/start-bitbucket.bat* h3. Expected Results When the following codepath runs in *start-bitbucket.bat*, it should exit immediately after *set-bitbucket-home.bat* returns errors: {code:title=start-bitbucket.bat} call %BIN_DIR%\set-bitbucket-home.bat if not errorlevel 0 exit /b if "%1" == "/no-search" set NO_SEARCH=1 echo Starting Atlassian Bitbucket {code} h3. Actual Results *start-bitbucket.bat* _does not exit_ and continues running, until the underlying problem causes another error to occur: {code} c:\Atlassian\Bitbucket\5.2.2\bin>start-bitbucket.bat Bitbucket doesn't know where to store its data. Configure the BITBUCKET_HOME environment variable with the directory where Bitbucket should store its data. Ensure the path to BITBUCKET_HOME does not contain spaces. BITBUCKET_HOME may be configured in set-bitbucket-home.bat, if preferred, rather than exporting it as an environment variable Starting Atlassian Bitbucket "_start-search.bat is not intended to be run directly. Run start-bitbucket.bat instead" "_start-webapp.bat is not intended to be run directly. Run start-bitbucket.bat instead" "To start the Bitbucket webapp without starting search, run start-bitbucket.bat /no-search" {code} h3. Workaround Substitute {{if not errorlevel 0}} for {{if errorlevel 1}}, which returns true for *all error levels greater than or equal to 1* |
New:
h3. Summary
Some of Bitbucket's .bat files use the following form to check for errors: {{if not errorlevel 0 …}} The problem is that Windows actually treats errorlevel comparison as a greater-than-or-equal-to operation. In other words, in the presence of errorlevel 1, the test {{if not errorlevel 0 …}} will actually return *false* instead of true. h3. Steps to Reproduce # Edit *set-bitbucket-home.bat* and comment out the value for {{BITBUCKET_HOME}}, eg.: {code:title=set-bitbucket-home.bat} rem set BITBUCKET_HOME=C:\\Atlassian\\ApplicationData\\Bitbucket {code}This will cause *set-bitbucket-home.bat* to return an error after it's called. # Run *<bitbucket-install>/bin/start-bitbucket.bat* h3. Expected Results When the following codepath runs in *start-bitbucket.bat*, it should exit immediately after *set-bitbucket-home.bat* returns errors: {code:title=start-bitbucket.bat} call %BIN_DIR%\set-bitbucket-home.bat if not errorlevel 0 exit /b if "%1" == "/no-search" set NO_SEARCH=1 echo Starting Atlassian Bitbucket {code}In other words, the following error should be printed, and then the script should immediately exit without proceeding further: {code} c:\Atlassian\Bitbucket\5.2.2\bin>start-bitbucket.bat Bitbucket doesn't know where to store its data. Configure the BITBUCKET_HOME environment variable with the directory where Bitbucket should store its data. Ensure the path to BITBUCKET_HOME does not contain spaces. BITBUCKET_HOME may be configured in set-bitbucket-home.bat, if preferred, rather than exporting it as an environment variable {code} h3. Actual Results *start-bitbucket.bat* _does not exit_ and continues running, until the underlying problem causes another error to occur: {code} c:\Atlassian\Bitbucket\5.2.2\bin>start-bitbucket.bat Bitbucket doesn't know where to store its data. Configure the BITBUCKET_HOME environment variable with the directory where Bitbucket should store its data. Ensure the path to BITBUCKET_HOME does not contain spaces. BITBUCKET_HOME may be configured in set-bitbucket-home.bat, if preferred, rather than exporting it as an environment variable Starting Atlassian Bitbucket "_start-search.bat is not intended to be run directly. Run start-bitbucket.bat instead" "_start-webapp.bat is not intended to be run directly. Run start-bitbucket.bat instead" "To start the Bitbucket webapp without starting search, run start-bitbucket.bat /no-search" {code} h3. Workaround Substitute {{if not errorlevel 0}} for {{if errorlevel 1}}, which returns true for *all error levels greater than or equal to 1* |
Description |
New:
h3. Summary
Some of Bitbucket's .bat files use the following form to check for errors: {{if not errorlevel 0 …}} The problem is that Windows actually treats errorlevel comparison as a greater-than-or-equal-to operation. In other words, in the presence of errorlevel 1, the test {{if not errorlevel 0 …}} will actually return *false* instead of true. h3. Steps to Reproduce # Edit *set-bitbucket-home.bat* and comment out the value for {{BITBUCKET_HOME}}, eg.: {code:title=set-bitbucket-home.bat} rem set BITBUCKET_HOME=C:\\Atlassian\\ApplicationData\\Bitbucket {code}This will cause *set-bitbucket-home.bat* to return an error after it's called. # Run *<bitbucket-install>/bin/start-bitbucket.bat* h3. Expected Results When the following codepath runs in *start-bitbucket.bat*, it should exit immediately after *set-bitbucket-home.bat* returns errors: {code:title=start-bitbucket.bat} call %BIN_DIR%\set-bitbucket-home.bat if not errorlevel 0 exit /b if "%1" == "/no-search" set NO_SEARCH=1 echo Starting Atlassian Bitbucket {code} h3. Actual Results *start-bitbucket.bat* _does not exit_ and continues running, until the underlying problem causes another error to occur: {code} c:\Atlassian\Bitbucket\5.2.2\bin>start-bitbucket.bat Bitbucket doesn't know where to store its data. Configure the BITBUCKET_HOME environment variable with the directory where Bitbucket should store its data. Ensure the path to BITBUCKET_HOME does not contain spaces. BITBUCKET_HOME may be configured in set-bitbucket-home.bat, if preferred, rather than exporting it as an environment variable Starting Atlassian Bitbucket "_start-search.bat is not intended to be run directly. Run start-bitbucket.bat instead" "_start-webapp.bat is not intended to be run directly. Run start-bitbucket.bat instead" "To start the Bitbucket webapp without starting search, run start-bitbucket.bat /no-search" {code} h3. Workaround Substitute {{if not errorlevel 0}} for {{if errorlevel 1}}, which returns true for *all error levels greater than or equal to 1* |