Skip to content

No clear syntax to avoid shellcheck SC2086 for expression substitutions #605

@williamrowell

Description

@williamrowell

Describe the bug
sprocket lint + shellcheck complains about unquoted placeholder expressions that are ignored by miniwdl check + shellcheck. Some of these are valid complaints, I think, but others don't have clear workarounds.

Example: {if threads > 1 then "--threads " + (threads - 1) else ""}

Because the leading -- is missing, it isn't treated as an option and shellcheck (when called by sprocket lint) flags it as SC2086.

Incidentally, miniwdl check + shellcheck also doesn't flag unquoted substitutions in filenames with SC2086, but I think the correct behavior is to flag those. I'm not sure what the appropriate solution for the longer expression substitutions should be, though.

Expected behavior
Ideally we'd have some workaround to handle command substitutions that wouldn't require suppressing the rule for the entire command.

Terminal Output

$ cat << EOF > samtools_index.wdl
version 1.0

task samtools_index {
  meta {
    description: "index a bam with samtools"
    outputs: {
      index: {
        description: "bam index"
      }
    }
  }

  parameter_meta {
    bam: {
      description: "aligned, sorted bam"
    }
  }

  input {
    File bam
  }

  Int threads = 4
  Int mem_gb = 8

  command <<<
    set -euo pipefail

    samtools index --bai \
      ~{if threads > 1 then "--threads " + (threads - 1) else ""} \
      --output ~{bam}.bai \
      ~{bam}
  >>>

  output {
    File index = "${bam}.bai"
  }

  runtime {
    docker: "quay.io/pacbio/pb_wdl_base@sha256:4b889a1f21a6a7fecf18820613cf610103966a93218de772caba126ab70a8e87"
    cpu: threads
    memory: mem_gb + " GiB"
  }
}

EOF

$ shellcheck --version

ShellCheck - shell script analysis tool
version: 0.9.0
license: GNU General Public License, version 3
website: https://www.shellcheck.net

$ sprocket --version

sprocket 0.20.1 (2026-02-04)

$ sprocket lint --report-mode one-line samtools_index.wdl

samtools_index.wdl:30:7: note[ShellCheck]: Double quote to prevent globbing and word splitting.
samtools_index.wdl:31:16: note[ShellCheck]: Double quote to prevent globbing and word splitting.
samtools_index.wdl:32:7: note[ShellCheck]: Double quote to prevent globbing and word splitting.

$ miniwdl version

miniwdl v1.13.1

$ miniwdl check --debug --strict samtools_index.wdl 

samtools_index.wdl
    task samtools_index

Environment (please complete the following information):

  • OS: linux, Rocky 9
  • Version: WDL version 1.0, sprocket 0.20.1
  • Shell: bash
  • Toolchain version: rustc 1.93.0 (254b59607 2026-01-19)

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions