trouble with shell egrep escaping chars

22 views
Skip to first unread message

Kai

unread,
Aug 3, 2016, 4:39:37 AM8/3/16
to Ansible Project
Dear all,

I cannot get the following line to work:

shell: "{{java_home}}/bin/java -version 2>&1 | grep 'java version' |
egrep '{{ '1\.[789]' | regex_escape() }}'"

Obviously this line already went through quite some iterations, but I
cannot get the YAML parser to even accept ist. It always throws a
"Syntax Error while loading YAML" with a mark pointing to the "\" character.

Is there any chance gatting this to work (or testing for a allowed range
of java version by any other means)?

Cheers, Kai

Kai Stian Olstad

unread,
Aug 3, 2016, 6:18:37 AM8/3/16
to ansible...@googlegroups.com
Escape the backslash and remove the regex_escape()

shell: "{{java_home}}/bin/java -version 2>&1 | grep 'java version' |
egrep '{{ '1\\.[789]' }}'"

--
Kai Stian Olstad

Kai

unread,
Aug 9, 2016, 11:21:12 AM8/9/16
to ansible...@googlegroups.com
G'day!
Yeah, this line passes the syntax check. Thanks a lot.

Cheers, Kai
Reply all
Reply to author
Forward
0 new messages