Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate process shell block #5508

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ Template scripts are generally discouraged due to the caveats described above. T

### Shell

:::{deprecated} 24.11.0-edge
Use the `script` block instead. Consider using the {ref}`VS Code extension <vscode-page>`, which provides syntax highlighting and error checking to distinguish Nextflow variables from Bash variables in the process script.
:::

The `shell` block is a string expression that defines the script that is executed by the process. It is an alternative to the {ref}`process-script` definition with one important difference: it uses the exclamation mark `!` character, instead of the usual dollar `$` character, to denote Nextflow variables.

This way, it is possible to use both Nextflow and Bash variables in the same script without having to escape the latter, which makes process scripts easier to read and maintain. For example:
Expand Down
23 changes: 7 additions & 16 deletions docs/reference/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ process sayHello {
}
```

A process may define additional sections for *directives*, *inputs*, *outputs*, *script*, *shell*, *exec*, and *stub*:
A process may define additional sections for *directives*, *inputs*, *outputs*, *script*, *exec*, and *stub*:

```nextflow
process greet {
Expand All @@ -202,7 +202,7 @@ process greet {
output:
stdout

script: // or shell: or exec:
script: // or exec:
"""
echo '${greeting}, ${name}!'
"""
Expand All @@ -214,27 +214,17 @@ process greet {
}
```

- A process must define a script, shell, or exec section (see below). All other sections are optional. Directives do not have an explicit section label, but must be defined first.
- A process must define a script or exec section (see below). All other sections are optional. Directives do not have an explicit section label, but must be defined first.

- The `script:` section label can be omitted only when there are no other sections in the body.

- Sections must be defined in the order shown above, with the exception of the output section, which can also be specified after the script and stub.

Each section may contain one or more statements. For directives, inputs, and outputs, these statements must be [function calls](#function-call). See {ref}`process-reference` for the set of available input qualifiers, output qualifiers, and directives.

The script section can be substituted with a shell or exec section:
The script section can be substituted with an exec section:

```nextflow
process greetShell {
input:
val greeting

shell:
'''
echo '!{greeting}, ${USER}!'
'''
}

process greetExec {
input:
val greeting
Expand All @@ -248,7 +238,7 @@ process greetExec {
}
```

The script, shell, and stub sections must return a string in the same manner as a [function](#function).
The script and stub sections must return a string in the same manner as a [function](#function).

See {ref}`process-page` for more information on the semantics of each process section.

Expand Down Expand Up @@ -356,7 +346,7 @@ Variables declared in a function, as well as the parameters of that function, ex

Workflow inputs exist for the entire workflow body. Variables declared in the main section exist for the main, emit, and publish sections. Named outputs are not considered variable declarations and therefore do not have any scope.

Process input variables exist for the entire process body. Variables declared in the process script, shell, exec, and stub sections exist only in their respective section, with one exception -- variables declared without the `def` keyword also exist in the output section.
Process input variables exist for the entire process body. Variables declared in the process script, exec, and stub sections exist only in their respective section, with one exception -- variables declared without the `def` keyword also exist in the output section.

Variables declared in an if or else branch exist only within that branch:

Expand Down Expand Up @@ -954,4 +944,5 @@ The following legacy features were excluded from this page because they are depr

- The `addParams` and `params` clauses of include declarations. See {ref}`module-params` for more information.
- The `when:` section of a process definition. See {ref}`process-when` for more information.
- The `shell:` section of a process definition. See {ref}`process-shell` for more information.
- The implicit `it` closure parameter. See {ref}`script-closure` for more information.
5 changes: 5 additions & 0 deletions docs/vscode.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
(vscode-page)=

# VS Code integration

Expand Down Expand Up @@ -431,6 +432,10 @@ The `each` process input is deprecated. Use the `combine` or `cross` operator to

The process `when` section is deprecated. Use conditional logic, such as an `if` statement or the `filter` operator, to control the process invocation in the calling workflow.

**Process shell section**

The process `shell` section is deprecated. Use the `script` block instead. The VS Code extension provides syntax highlighting and error checking to help distinguish between Nextflow variables and Bash variables.

### Configuration syntax

See {ref}`config-syntax` for a comprehensive description of the configuration language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,9 @@ class NextflowDSLImpl implements ASTTransformation {
readSource(stm,source,unit)
break

case 'script':
case 'shell':
log.warn "The `shell` block is deprecated, use `script` instead"
case 'script':
bodyLabel = currentLabel
iterator.remove()
execStatements << stm
Expand Down
Loading