[Solved] Catch-all helper for Makefile when the possible arguments can include a colon character (:)


You will probably get more mileage leveraging make invocation conventions (which expect make to take list of targets to build). It’s going to be hard to different argument style. Consider the alternatives:

Using variable to pass parameter to the console

make console CMD=cache:clear

Makefile:
console:
    docker-compose exec core19app sh -c "php bin/console $(CMD)"

Or using pseudo-targets cmd-SOMETHING

make console-cache:clear

Makefile
console-%:
    docker-compose exec core19app sh -c "php bin/console $(@:console-%=%)"

As last resort, consider small wrapper ‘make-console’ to make for more friendly command line interface, if users need it.

#! /bin/sh
make console CMD="$1"

2

solved Catch-all helper for Makefile when the possible arguments can include a colon character (:)