Bastian Venthur
Bastian Venthur

Reputation: 16600

Escaping parentheses in Makefile rule with bash <(curl ...)

I want to run the infamous bash <(curl SOME_URL) combo in a Makefile and I'm struggling with escaping of the parenthesis. The relevant excerpt from the Makefile looks like this:

foo:
    docker run $(IMAGE_NAME) bash <(curl SOME_URL) \
        --some-param1 \
        --some-param2

Running the above via make foo only yields: /bin/sh: 1: Syntax error: "(" unexpected

Can someone show me how to escape the parenthesis properly so I can execute the above

Upvotes: 2

Views: 2612

Answers (1)

Inian
Inian

Reputation: 85683

The reason is because, you are not using the bash shell. Your makefile does not use the bourne again shell (bash) in which process substitution is supported(<()), so the system executes it with /bin/sh. The default /bin/sh bourne shell is designed to run only with standard features.

Use the SHELL := /bin/bash in your Makefile to make the bash shell by default for all the recipes, or you could define it per recipe.

foo: SHELL := /bin/bash
foo:
    docker run $(IMAGE_NAME) bash <(curl SOME_URL) \
        --some-param1 \
        --some-param2

From GNU make documentation: Choosing the Shell. Quoting from it to show the actual lines

The program used as the shell is taken from the variable SHELL. If this variable is not set in your makefile, the program /bin/sh is used as the shell

Upvotes: 7

Related Questions