You are not logged in.

#1 2016-08-04 23:05:21

FlowIt
Member
Registered: 2014-10-25
Posts: 239

[Autotools] Using AC_SUBST for Bash code

In my configure.ac I have something like this:

if cond; then
  HASH_PARSER='${tmp=${sum##*:};tmp=${tmp% *};tmp=${tmp// /}}'
else
  HASH_PARSER=...
fi
AC_SUBST(HASH_PARSER)

I don't know if this is good style or not, but depending on the configure flags this small bash snippet changes, so I can substitute the appropriate "parser".
This example here won't compile, because I get an "unterminated variable reference" error in my Makefile. So I need to escape this snippet in my Makefile but make sure to subsitute it exactly as it is in my configure script. And this is where I am stuck.

Last edited by FlowIt (2016-08-04 23:32:27)

Offline

#2 2016-08-04 23:17:45

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Autotools] Using AC_SUBST for Bash code

What do you expect '${${${sum##*:}% *}// /}' to do? Assuming it's even syntactically valid, I would think the inner two PEs would have to resolve to variable names and eval would have to be involved somehow.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#3 2016-08-04 23:32:10

FlowIt
Member
Registered: 2014-10-25
Posts: 239

Re: [Autotools] Using AC_SUBST for Bash code

It is supposed to be a chain of string operations, but you are absolutly right, the snippet given is garbage. I edited my first post to show an example which would work in bash, but it not correctly subsituted.

Last edited by FlowIt (2016-08-04 23:33:05)

Offline

Board footer

Powered by FluxBB