m4

M4 sees end of file in string


I'm getting a m4-parsing error that it sees an EOF character in the 2nd line of the following set of lines (which will be executed in a seperate shell:

     "set V1 = `grep -c  'z = 10\.0e-6'     qt_data/kxfo_ssr_udfo_tmp/* | wc -l`;\
      set V2 = `grep -c  'z = -30\.0e-6'    qt_data/kxfo_ssr_udfo_tmp/* | wc -l`;\
      test $V1 > 0;\
      test $V1 = $V2 "

The error I get is: <path-to-file>:<line>:ERROR: end of file in string

(For clarity: the line that gives the issue is: set V2 = `grep -c 'z = -30\.0e-6' qt_data/kxfo_ssr_udfo_tmp/* | wc -l`;\)

I'm trying to find out which of the character combinations is seen by M4 and how to escape that as EOF since the command in itself works without problems in a shell.

Does anybody know how I can fix the error since I cannot find the character-combi that is seen as EOF by M4?


Solution

  • A not ideal although workable solution might be to use the changequote built-in macro:

    1. Choose an non-existent character to be considered as a start quote and an end character to be considered as an end quote. For instance: changequote("""", """); here, you are saying to the m4 interpreter that """" is a start quote and """ is an end quote from now on until the interpreter finds the macro changequote().

    2. To reverse this behavior (meaning, go back to the standard definition of quotes from the point you do not wish this assumption anymore), you need to use the built-in macro changequote() without parameters.