configure_file: escaping (single) quotes

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

configure_file: escaping (single) quotes

Franck Houssen
Hello,

I need configure_file to produce a bash file containing this line:
VAR="${VAR//'#'/}"

I tried without success VAR="${VAR//'#'/}" and VAR="${VAR//\'#\'/}" with and without ESCAPE_QUOTES in configure_file : always get an error like "Syntax error in cmake code when parsing string".
Not a bash guru, and, can't get if the problem comes from bash or cmake... Can somebody help on this ?

Franck

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: configure_file: escaping (single) quotes

CHEVRIER, Marc

The problem comes from CMake evaluating variable VAR (i.e. expression ${VAR…}) and detect wrong syntax.

The solution is to specify option @ONLY to command configure_file to avoid ${} evaluation.

 

 

From: CMake <[hidden email]> on behalf of Franck Houssen <[hidden email]>
Date: Tuesday 9 January 2018 at 10:24
To: CMake Mail List <[hidden email]>
Subject: [CMake] configure_file: escaping (single) quotes

 

VAR="${VAR//'#'/}"


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: configure_file: escaping (single) quotes

J Decker
In reply to this post by Franck Houssen


On Tue, Jan 9, 2018 at 1:24 AM, Franck Houssen <[hidden email]> wrote:
Hello,

I need configure_file to produce a bash file containing this line:
VAR="${VAR//'#'/}"


maybe 

VAR="$" "{VAR//'#'/}"
 
I tried without success VAR="${VAR//'#'/}" and VAR="${VAR//\'#\'/}" with and without ESCAPE_QUOTES in configure_file : always get an error like "Syntax error in cmake code when parsing string".
Not a bash guru, and, can't get if the problem comes from bash or cmake... Can somebody help on this ?

Franck

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: configure_file: escaping (single) quotes

J Decker


On Tue, Jan 9, 2018 at 1:29 AM, J Decker <[hidden email]> wrote:


On Tue, Jan 9, 2018 at 1:24 AM, Franck Houssen <[hidden email]> wrote:
Hello,

I need configure_file to produce a bash file containing this line:
VAR="${VAR//'#'/}"


maybe 

VAR="$" "{VAR//'#'/}"
Oh nevermind I was doing that sort of thing using FILE( APPEND ... )
 

 
I tried without success VAR="${VAR//'#'/}" and VAR="${VAR//\'#\'/}" with and without ESCAPE_QUOTES in configure_file : always get an error like "Syntax error in cmake code when parsing string".
Not a bash guru, and, can't get if the problem comes from bash or cmake... Can somebody help on this ?

Franck

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: configure_file: escaping (single) quotes

Franck Houssen
In reply to this post by CHEVRIER, Marc

De: "Marc CHEVRIER" <[hidden email]>
À: "Franck Houssen" <[hidden email]>, "CMake Mail List" <[hidden email]>
Envoyé: Mardi 9 Janvier 2018 10:29:30
Objet: Re: [CMake] configure_file: escaping (single) quotes

The problem comes from CMake evaluating variable VAR (i.e. expression ${VAR…}) and detect wrong syntax.

The solution is to specify option @ONLY to command configure_file to avoid ${} evaluation.


The line after VAR is something like:

VAR="${VAR//'#'/}"

CMD="mpirun -n ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS}"


I need MPIEXEC_* to be replaced. So, I need to use @ONLY and set all MPIEXEC variables with @ (but not $). Correct ?


 

 

From: CMake <[hidden email]> on behalf of Franck Houssen <[hidden email]>
Date: Tuesday 9 January 2018 at 10:24
To: CMake Mail List <[hidden email]>
Subject: [CMake] configure_file: escaping (single) quotes

VAR="${VAR//'#'/}"



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: configure_file: escaping (single) quotes

CHEVRIER, Marc

Yes, you have to rewrite your line as:

CMD="mpirun -n @MPIEXEC_PREFLAGS@ @MPIEXEC_NUMPROC_FLAG@ @MPIEXEC_MAX_NUMPROCS@ @MPIEXEC_POSTFLAGS@"

 

 

From: Franck Houssen <[hidden email]>
Date: Tuesday 9 January 2018 at 11:23
To: "CHEVRIER, Marc" <[hidden email]>
Cc: CMake Mail List <[hidden email]>
Subject: Re: [CMake] configure_file: escaping (single) quotes

 


De: "Marc CHEVRIER" <[hidden email]>
À: "Franck Houssen" <[hidden email]>, "CMake Mail List" <[hidden email]>
Envoyé: Mardi 9 Janvier 2018 10:29:30
Objet: Re: [CMake] configure_file: escaping (single) quotes

 

The problem comes from CMake evaluating variable VAR (i.e. expression ${VAR…}) and detect wrong syntax.

The solution is to specify option @ONLY to command configure_file to avoid ${} evaluation.

 

The line after VAR is something like:

VAR="${VAR//'#'/}"

CMD="mpirun -n ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS}"



I need MPIEXEC_* to be replaced. So, I need to use @ONLY and set all MPIEXEC variables with @ (but not $). Correct ?

 

 

 

From: CMake <[hidden email]> on behalf of Franck Houssen <[hidden email]>
Date: Tuesday 9 January 2018 at 10:24
To: CMake Mail List <[hidden email]>
Subject: [CMake] configure_file: escaping (single) quotes

VAR="${VAR//'#'/}"

 


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: configure_file: escaping (single) quotes

Franck Houssen
OK. Got it to work ! Thanks


De: "Marc CHEVRIER" <[hidden email]>
À: "Franck Houssen" <[hidden email]>
Cc: "CMake Mail List" <[hidden email]>
Envoyé: Mardi 9 Janvier 2018 11:26:55
Objet: Re: [CMake] configure_file: escaping (single) quotes

Yes, you have to rewrite your line as:

CMD="mpirun -n @MPIEXEC_PREFLAGS@ @MPIEXEC_NUMPROC_FLAG@ @MPIEXEC_MAX_NUMPROCS@ @MPIEXEC_POSTFLAGS@"

 

 

From: Franck Houssen <[hidden email]>
Date: Tuesday 9 January 2018 at 11:23
To: "CHEVRIER, Marc" <[hidden email]>
Cc: CMake Mail List <[hidden email]>
Subject: Re: [CMake] configure_file: escaping (single) quotes

 


De: "Marc CHEVRIER" <[hidden email]>
À: "Franck Houssen" <[hidden email]>, "CMake Mail List" <[hidden email]>
Envoyé: Mardi 9 Janvier 2018 10:29:30
Objet: Re: [CMake] configure_file: escaping (single) quotes

 

The problem comes from CMake evaluating variable VAR (i.e. expression ${VAR…}) and detect wrong syntax.

The solution is to specify option @ONLY to command configure_file to avoid ${} evaluation.

 

The line after VAR is something like:

VAR="${VAR//'#'/}"

CMD="mpirun -n ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS}"



I need MPIEXEC_* to be replaced. So, I need to use @ONLY and set all MPIEXEC variables with @ (but not $). Correct ?

 

 

 

From: CMake <[hidden email]> on behalf of Franck Houssen <[hidden email]>
Date: Tuesday 9 January 2018 at 10:24
To: CMake Mail List <[hidden email]>
Subject: [CMake] configure_file: escaping (single) quotes

VAR="${VAR//'#'/}"

 



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake