Makefile not accepting conditionals

Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I am using the following conditional statement within a Makefile:
mytarget:
if [ -z "$TAG1" | -z "$TAG2" | -z "$TAG3" ]
then
echo "Need to set all tag names images
exit 1
fi
but then ...
$ make mytarget TAG1=latest TAG2=latest TAG3=latest
if [ -z "latest" | -z "latest" | -z "latest" ]
/bin/bash: -c: line 1: syntax error: unexpected end of file
Makefile:36: recipe for target 'env' failed
make: *** [env] Error 1
bash make
add a comment |Â
up vote
-1
down vote
favorite
I am using the following conditional statement within a Makefile:
mytarget:
if [ -z "$TAG1" | -z "$TAG2" | -z "$TAG3" ]
then
echo "Need to set all tag names images
exit 1
fi
but then ...
$ make mytarget TAG1=latest TAG2=latest TAG3=latest
if [ -z "latest" | -z "latest" | -z "latest" ]
/bin/bash: -c: line 1: syntax error: unexpected end of file
Makefile:36: recipe for target 'env' failed
make: *** [env] Error 1
bash make
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am using the following conditional statement within a Makefile:
mytarget:
if [ -z "$TAG1" | -z "$TAG2" | -z "$TAG3" ]
then
echo "Need to set all tag names images
exit 1
fi
but then ...
$ make mytarget TAG1=latest TAG2=latest TAG3=latest
if [ -z "latest" | -z "latest" | -z "latest" ]
/bin/bash: -c: line 1: syntax error: unexpected end of file
Makefile:36: recipe for target 'env' failed
make: *** [env] Error 1
bash make
I am using the following conditional statement within a Makefile:
mytarget:
if [ -z "$TAG1" | -z "$TAG2" | -z "$TAG3" ]
then
echo "Need to set all tag names images
exit 1
fi
but then ...
$ make mytarget TAG1=latest TAG2=latest TAG3=latest
if [ -z "latest" | -z "latest" | -z "latest" ]
/bin/bash: -c: line 1: syntax error: unexpected end of file
Makefile:36: recipe for target 'env' failed
make: *** [env] Error 1
bash make
asked Jun 28 at 11:14
pkaramol
201111
201111
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
You need to have backslashes at the end of each (but the last) command line.
make sends each command line to a separate shell using: /bin/sh -ce "cmdline"
Note that since you don't have the newlines in the shell anymore, you may need to add a semicolon at before the backslash newline for some commands, e.g.
target:
if true;
then
echo true;
fi
the backslash causes that make converts all these virtual lines to:
if true; then echo true; fi
before sending it to /bin/sh -ce cmd.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You need to have backslashes at the end of each (but the last) command line.
make sends each command line to a separate shell using: /bin/sh -ce "cmdline"
Note that since you don't have the newlines in the shell anymore, you may need to add a semicolon at before the backslash newline for some commands, e.g.
target:
if true;
then
echo true;
fi
the backslash causes that make converts all these virtual lines to:
if true; then echo true; fi
before sending it to /bin/sh -ce cmd.
add a comment |Â
up vote
0
down vote
You need to have backslashes at the end of each (but the last) command line.
make sends each command line to a separate shell using: /bin/sh -ce "cmdline"
Note that since you don't have the newlines in the shell anymore, you may need to add a semicolon at before the backslash newline for some commands, e.g.
target:
if true;
then
echo true;
fi
the backslash causes that make converts all these virtual lines to:
if true; then echo true; fi
before sending it to /bin/sh -ce cmd.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You need to have backslashes at the end of each (but the last) command line.
make sends each command line to a separate shell using: /bin/sh -ce "cmdline"
Note that since you don't have the newlines in the shell anymore, you may need to add a semicolon at before the backslash newline for some commands, e.g.
target:
if true;
then
echo true;
fi
the backslash causes that make converts all these virtual lines to:
if true; then echo true; fi
before sending it to /bin/sh -ce cmd.
You need to have backslashes at the end of each (but the last) command line.
make sends each command line to a separate shell using: /bin/sh -ce "cmdline"
Note that since you don't have the newlines in the shell anymore, you may need to add a semicolon at before the backslash newline for some commands, e.g.
target:
if true;
then
echo true;
fi
the backslash causes that make converts all these virtual lines to:
if true; then echo true; fi
before sending it to /bin/sh -ce cmd.
edited Jun 28 at 15:10
answered Jun 28 at 11:23
schily
8,57421435
8,57421435
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452413%2fmakefile-not-accepting-conditionals%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password