Forwarding all batch file parameters to inner command
17,734
Solution 1
in your batch file composer.bat, simply put:
php C:\path\to\composer\composer.phar %*
Solution 2
windows gives you %*
to refer to all parameters.
Your new composer.bat file will then become
php C:\path\to\composer\composer.phar %*
Comments
-
Szopinski almost 2 years
For my comfort in Windows, I want to prepare some PHP tools launched like in Unix.
f.e.:
composer create-project symfony/framework-standard-edition path/
Not:
php composer.phar create-project symfony/framework-standard-edition path/
I made composer.bat file in system path dir:
php C:\path\to\composer\composer.phar
and its works in simply usage. But how to forward all parameter and flags to command inside?
-
David A. Gray over 6 yearsI just put that together, combining a Windows NT command script (a .CMD file) with a standard desktop shortcut that has its working directory (start in) property set to the name of the project root directory. This is a real PITA for a "dynamic" scripting language, but I have a tolerable solution.
-
Eric over 5 yearsThis fails for
composer.bat "^^"
and swallows all the carets! -
Justin German over 5 yearsThat's not the case on my machine with a default command prompt. The carets get passed on to the next script.
-
Eric over 5 yearsYou're right - the problem only arises when invoked via
execv
or similar -
Justin German over 5 years@Eric So this is probably more an issue of properly escaping the arguments than what this original question is about (and a downvote seems a little harsh...). But I just saw that someone pointed this already out in your question.