Skip to content

Commit 6f52755

Browse files
Deprecate process shell block (#5508)
Signed-off-by: Ben Sherman <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]>
1 parent 8fbf8ff commit 6f52755

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

docs/process.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ Template scripts are generally discouraged due to the caveats described above. T
212212

213213
### Shell
214214

215+
:::{deprecated} 24.11.0-edge
216+
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.
217+
:::
218+
215219
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.
216220

217221
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:

docs/reference/syntax.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ process sayHello {
187187
}
188188
```
189189

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

192192
```nextflow
193193
process greet {
@@ -202,7 +202,7 @@ process greet {
202202
output:
203203
stdout
204204
205-
script: // or shell: or exec:
205+
script: // or exec:
206206
"""
207207
echo '${greeting}, ${name}!'
208208
"""
@@ -214,27 +214,17 @@ process greet {
214214
}
215215
```
216216

217-
- 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.
217+
- 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.
218218

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

221221
- 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.
222222

223223
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.
224224

225-
The script section can be substituted with a shell or exec section:
225+
The script section can be substituted with an exec section:
226226

227227
```nextflow
228-
process greetShell {
229-
input:
230-
val greeting
231-
232-
shell:
233-
'''
234-
echo '!{greeting}, ${USER}!'
235-
'''
236-
}
237-
238228
process greetExec {
239229
input:
240230
val greeting
@@ -248,7 +238,7 @@ process greetExec {
248238
}
249239
```
250240

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

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

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

357347
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.
358348

359-
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.
349+
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.
360350

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

@@ -958,4 +948,5 @@ The following legacy features were excluded from this page because they are depr
958948

959949
- The `addParams` and `params` clauses of include declarations. See {ref}`module-params` for more information.
960950
- The `when:` section of a process definition. See {ref}`process-when` for more information.
951+
- The `shell:` section of a process definition. See {ref}`process-shell` for more information.
961952
- The implicit `it` closure parameter. See {ref}`script-closure` for more information.

docs/vscode.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
(vscode-page)=
12

23
# VS Code integration
34

@@ -443,6 +444,10 @@ The `each` process input is deprecated. Use the `combine` or `cross` operator to
443444

444445
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.
445446

447+
**Process shell section**
448+
449+
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.
450+
446451
### Configuration syntax
447452

448453
See {ref}`config-syntax` for a comprehensive description of the configuration language.

modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ class TaskProcessor {
309309
this.ownerScript = script
310310
this.config = config
311311
this.taskBody = taskBody
312+
if( taskBody.isShell )
313+
log.warn "Process ${name} > the `shell` block is deprecated, use `script` instead"
312314
this.name = name
313315
this.maxForks = config.maxForks && config.maxForks>0 ? config.maxForks as int : 0
314316
this.forksCount = maxForks ? new LongAdder() : null

0 commit comments

Comments
 (0)