mirror of
https://github.com/ruby/ruby.git
synced 2026-07-31 09:25:15 +08:00
Introduce shellsplit.cmd command line parsing subroutine. Dealing with the limitations of cmd.exe's command-line parsing forces users to use workarounds, and corner cases still remain. By implementing our own command line splitting, we conceal the complexity and ensure maintainability. Makefile macro definition and opt-dir list now free from quoting. now can use like ``` configure.bat --with-opt-dir=c:/src/zlib;c:/src/libffi CC="cl -std:c11" DEFS=-DOPT_THREADED_CODE=2 ```
29 lines
749 B
Batchfile
29 lines
749 B
Batchfile
@echo off & if not [%1]==[] goto :process
|
|
|
|
echo.
|
|
echo This script demonstrates how shellsplit.cmd works.
|
|
echo usage: %0 arg1 arg2...
|
|
echo.
|
|
echo Prints separated arguments as (arg1)(arg2)...
|
|
echo - splits commandline with spaces/tabs. cmd.exe standard rule is ignored.
|
|
echo - you can use double quotes to contain spaces/tabs into an argument.
|
|
echo - you can not escape double quote.
|
|
echo - solitary "" is ignored since cmd.exe variables cannot represent empty value.
|
|
exit /b 0
|
|
|
|
:process
|
|
setlocal
|
|
set V=0
|
|
|
|
:: %* can contain meta character inside quote. do not use set "args=%*" here.
|
|
set args=%*
|
|
|
|
:loop
|
|
call %~dp0\shellsplit.cmd
|
|
if not defined argv goto :end
|
|
set /p "tmp=(%argv%)"<NUL
|
|
goto :loop
|
|
|
|
:end
|
|
endlocal & exit /b 0
|