Skip to content

When using shell in processes, some backslashes still need to be escaped #67

Description

@mfoll

In this sed command, the backslashes need to be escaped when used in shell:

bash-3.2$ echo "Hello lg:en" | sed "s/.*lg:\(.*\).*/\1/"
en

In a nextflow shell process (see below), this would result in:

ERROR ~ startup failed:
test.nf: 11: unexpected char: '\' @ line 11, column 29.
     echo "!{x}" | sed "s/.*lg:\(.*\).*/\1/"

But it works when escaping the three backslashes. However, the \t in printf "This \t works" doesn't need to be escaped:

echo true

cheers = Channel.from 'Bojour lg:fr', 'Ciao lg:it', 'Hello lg:en', 'Hola lg:es', 'Γεια σου lg:gr'

process sayHello {
  input: 
  val x from cheers

  shell:
  '''
  echo "!{x}" | sed "s/.*lg:\\(.*\\).*/\\1/"
  printf "This \t works"
  '''
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions