::
:: bq.bat - Backquote command substitution and response files for WinXP.
::
:: Jason Hood, 26 March, 2005.
::
@echo off
SetLocal EnableExtensions EnableDelayedExpansion
set Q=
if "%~1"=="-q" set Q=^"& shift &::" ::balance quote for syntax highlighting
set PROG=%1
if not defined PROG goto help
if "%~1"=="/?" goto help
if "%~1"=="-h" goto help
if "%~1"=="--help" goto help
:loop1
shift
set arg=%1
if not defined arg goto :exec
if not ^%arg:~0,1%==^` (
if ^%arg:~0,1%==^@ (
for /F "usebackq delims=" %%i in (!arg:~1!) do set PROG=!PROG! %Q%%%i%Q%
) else (
set PROG=%PROG% %1
)
goto loop1
)
set CMD=
:loop2
set CMD=%CMD% %1
if ^%arg:~-1,1%==^` goto sub
shift
set arg=%1
if defined arg goto loop2
set CMD=%CMD%`
:sub
for /F "usebackq delims=" %%i in (%CMD%) do set PROG=!PROG! %Q%%%i%Q%
goto :loop1
:exec
%PROG%
goto :eof
:help
SetLocal DisableDelayedExpansion
set help=
for /F "skip=58 delims=" %%L in (%~f0) do (
if defined help (
if "%%L" == "." (echo.) else echo %%L
) else (
if "%%L" == "::Help" set help=1
)
)
goto :eof
::Help
BQ by Jason Hood .
Version 1.00 (26 March, 2005). Public Domain.
http://misc.adoxa.cjb.net/
.
Backquote command substitution and response files for WinXP.
.
bq [-q] program [arguments] [`command`] [@file]
.
-q quote each line from COMMAND or FILE
.
Notes:
.
* All the options can appear in any order and any quantity.
* Nesting is not supported (` & @ from COMMAND or FILE are literals).
* Quote the argument to use a literal ` or @.
* To use a FILE with spaces, place the quotes after the @ (@"file name").
.
Example:
.
bq upx -9 `unzip -Z1 pkg *.exe` @exe.lst
.
would compress all the (extracted) executables in PKG.ZIP and all the files
listed in EXE.LST.
               (
geocities.com/jadoxa)