Skip to main content

Command Palette

Search for a command to run...

How to pass an argument with spaces to a make command.

Published
1 min read
How to pass an argument with spaces to a make command.
E

A self-driven software engineer with a solid technical background and over 7 years of experience building scalable and resilient web applications across real-estate, logistics and delivery industries.
I am passionate about helping beginners gain a solid footing in the tech industry through personal coaching and mentorship.

In this article, I document for my future self how to pass an argument with spaces to a make command.
For context, in my makefile, I have a command that uses alembic to generate migrations for some SQLAlchemy models.
The detail of the command depends on context, but here it is for completeness sake:

make-migration:
    cd src && poetry run alembic revision --autogenerate -m '$(msg)'

where msg is the argument I need to pass in when running the command.
Assuming I have just added a user table, and would like to run the migration for it. The command is as follows:

make msg="add user table" make-migration

Note that msg is is separated by spaces. And for the command to work, the argument in the make-migration has to be surrounded by a space like so: '$(msg)'