You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem here is that the backslash character is interpreted by the Groovy syntax parser as the string escape character. Thus is no way to fix this.
Note that \n and \t are not managed in a special way, they are simply replaced with the equivalent special character #13 and #09 in the produced shell script.
There are two possible workarounds to handle your use case.
The first, Groovy allows an alternative syntax for string definitions which uses the $ as escape character in place of \ character. These strings are delimited with an opening $/ and and a closing /$. Thus your script should be defined like this:
shell:
$/
echo "Hello lg:en" | sed "s/.*lg:\(.*\).*/\1/"
/$
However note that $SOMETHING will be parsed as a string variable. You can read more about this string syntax here.
Another option is to include your script into a external template. For example you could have a file
Thanks for the suggestions. The dollar slashy string is still not a perfect solution (in term of having pure bash code inside), as one has to escape the dollar sign now with a dollar. For example when using a bash variable:
shell:
$/
lang=$(echo "!{x}" | sed "s/.*lg:\(.*\).*/\1/")
echo "$$lang"
/$
Anyway, that's clearly a minor point, and having templates is a good workaround.
In this sed command, the backslashes need to be escaped when used in shell:
In a nextflow shell process (see below), this would result in:
But it works when escaping the three backslashes. However, the
\t
inprintf "This \t works"
doesn't need to be escaped:The text was updated successfully, but these errors were encountered: