Quantcast

Why execute_process failed escape sequence \/?

classic Classic list List threaded Threaded
3 messages Options
hce
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why execute_process failed escape sequence \/?

hce
Hi,

I can most of shell commands in execute_process(), but cmake failed at following errors when I added "sed 's/^.\///g'" to execute_process():

Syntax error in cmake code, when parsing string 's/^.\///g', Invalid escape sequence \/, Call Stack ...

But without the escape sequence \/, the shell command could not run, how can I make the execute_process() run shell command with escape sequence \/ ?

Thank you.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why execute_process failed escape sequence \/?

Rolf Eike Beer
> Hi,
>
> I can most of shell commands in execute_process(), but cmake failed at
> following errors when I added "sed 's/^.\///g'" to execute_process():
>
> Syntax error in cmake code, when parsing string 's/^.\///g', Invalid
> escape
> sequence \/, Call Stack ...
>
> But without the escape sequence \/, the shell command could not run, how
> can
> I make the execute_process() run shell command with escape sequence \/ ?

You must escape the backslash, so it doesn't get stripped by the CMake
parser: 's/^.\\///g'

Bonus trick: you can avoid it altogether by just using a different
character as delimiter: 's,^./,,g'

Just wondering: do you want to work on some find output? Then you also
need to escape the ".".

Eike
--

Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
hce
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why execute_process failed escape sequence \/?

hce
Thanks Eike.

Cheers.
Loading...