Prechádzať zdrojové kódy

Handle goma_ctl/autoninja /?

With nested batch files it is very common for /? arguments to end up
being interpreted as a request for help on the batch file "call"
command. That is, if a user invokes "goma_ctl /?" then this turns into
something like this:
  @call ...\python3.bat %~dp0\.cipd_bin\goma_ctl.py %*
The name of the script to be invoked is ignored and this is treated
like:
  @call /?

This is particularly problematic for commands like goma_ctl and
autoninja which don't print help if no arguments are passed, thus
making finding the correct help incantation slightly challenging.

This special-cases /? in these two batch files. Some other common batch
files were tested and found to be not affected, so while this is not a
complete fix it does hit some of the most important places.

Change-Id: Ic9b0455c2f8b085666862bc4495d9bad445dfeaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4080991
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Bruce Dawson 2 rokov pred
rodič
commit
25334bb18e
2 zmenil súbory, kde vykonal 10 pridanie a 0 odobranie
  1. 6 0
      autoninja.bat
  2. 4 0
      goma_ctl.bat

+ 6 - 0
autoninja.bat

@@ -7,6 +7,12 @@ setlocal
 
 set scriptdir=%~dp0
 
+if "%*" == "/?" (
+  rem Handle "autoninja /?" which will otherwise give help on the "call" command
+  @call python3.bat %~dp0\ninja.py --help
+  exit /b
+)
+
 if not defined AUTONINJA_BUILD_ID (
   :: Set unique build ID.
   FOR /f "usebackq tokens=*" %%a in (`%scriptdir%python-bin\python3.bat -c "import uuid; print(uuid.uuid4())"`) do set AUTONINJA_BUILD_ID=%%a

+ 4 - 0
goma_ctl.bat

@@ -8,5 +8,9 @@
 set scriptdir=%~dp0
 
 @call "%~dp0\cipd_bin_setup.bat" > nul 2>&1
+if "%*" == "/?" (
+  @call %scriptdir%python-bin\python3.bat %~dp0\.cipd_bin\goma_ctl.py --help
+  exit /b
+)
 @call %scriptdir%python-bin\python3.bat %~dp0\.cipd_bin\goma_ctl.py %*
 exit /b %ERRORLEVEL%