Skip to content

Instantly share code, notes, and snippets.

@miteshmap
Created January 30, 2023 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miteshmap/b52cb549c4a590d286189c69c83e8907 to your computer and use it in GitHub Desktop.
Save miteshmap/b52cb549c4a590d286189c69c83e8907 to your computer and use it in GitHub Desktop.
Makefile
# Split all arguments for easier use in commands.
# You can now use the variables: ${ARGS} ${ARG_1} ${ARG_2} ${ARG_3} ${ARG_REST}
# @see https://stackoverflow.com/questions/2214575/passing-arguments-to-make-run#answer-45003119
ARGS = $(filter-out $@,$(MAKECMDGOALS))
ARG_1 = $(word 1, ${ARGS})
ARG_2 = $(word 2, ${ARGS})
ARG_3 = $(word 3, ${ARGS})
ARG_REST = $(wordlist 2, 100, ${ARGS})
## We use the following rule/recipe to prevent errors messages when passing arguments in make commands
## @see https://stackoverflow.com/a/6273809/1826109
%:
@:
run:
ddev exec -d /var/www/html/docroot ${ARG_1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment