0
votes

I have the following (part of a larger multiline bash script) in my makefile. The variables A, B come from shell command execution via $$(...), but the code below is enough to reproduce the problem:

test:
    A=1; \
    B=2; \
    diff < ( echo $$A ) < ( echo $$B ) || exit 1

syntax error near unexpected token `('.

How can this be done in make? I know there is ifeq and similar in Makefile, but I guess its not suitable for multiline bash scripts in Makefiles.

2
Dont leave a space between <(. Also $$ is the PID of the current process so you are comparing PIDA and PIDB, you never use the variables you set. - 123
@User112638726 In his Makefile context, $$ will result in the shell seing $. - PSkocik
@PSkocik ahh right, my bad. - 123

2 Answers

2
votes

The default shell is /bin/sh which doesn't have Process Substitution. You need to change the shell:

SHELL:=/bin/bash
test:
    A=1; \
    B=2; \
    diff <( echo $$A ) <( echo $$B ) || exit 1
2
votes

The correct syntax of Process substitution is

<( echo $$A )

i.e. no space between < and (.

Be sure to specify

SHELL ::= /bin/bash

or some other shell that supports it.