KoblentsBlog Photography
Contact About
Escaping $ in Makefile Define
Had an annoying bug that didn't seem to show up on google... so maybe this will resolve some issues.
I have a makefile where a build is attempted, but because the build tool is buggy, sometimes it fails for no reason. So I invoke it with a timeout, then test to see if it errored out, and if so I rerun the build. The error code in bash is $?; but inside of a makefile the $ needs to be escaped, so I write
if [ $$? -ne 0]; then
However, if you need to stick this into a makefile #define block, you need to escape the escaped $. If you don't, you'll get this error: -ne: unary operator expected. So you'll have to do this:
if [ $$$$? -ne 0 ]; then
in order to escape things properly.
Ches Koblents
February 26, 2017
« Newer Older »
© Copyright Koblents.com, 2012-2017