Reputation: 1405
I'm trying to throw an error with Make command. This is my makefile:
exit:
val=1
exit $(val)
However, when I run make exit && echo $?
it gave me exit code 0. I was expecting exit code 1.
Did I use it wrong? Appreciate it.
Upvotes: 4
Views: 6583
Reputation: 58768
$(name)
, and shell variables, declared as part of a command inside a target and referenced using $${name}
.What you want is either a single command equivalent to val=1 && exit $val
:
exit:
val=1 && exit $${val}
or a makefile variable used in a simple command:
val = 1
exit:
exit $(val)
Upvotes: 4