Skip to content

shellcheck/SC1040

When using <<-, the heredoc terminator may only be indented with tabs.

Property Value
Severity Error
Category Best Practices
Default Enabled (via shellcheck/*)
Auto-fix Yes (--fix, safe)

Description

The <<- heredoc form strips leading tabs from heredoc lines. Leading spaces before the terminator are invalid and can prevent correct heredoc termination.

tally reports this as shellcheck/SC1040 and provides an auto-fix that removes only the extra leading spaces from the terminator indentation.

Examples

Problematic code

RUN <<'SCRIPT'
cat <<-EOF
hello
  EOF
EOF
SCRIPT

Correct code

RUN <<'SCRIPT'
cat <<-EOF
hello
    EOF
EOF
SCRIPT

Auto-fix

The fix is minimal:

  • removes only leading space runs in the offending terminator line
  • preserves tab indentation
  • emits narrow edits so other fixes can still apply to the same script
tally lint --fix --select shellcheck/SC1040 Dockerfile

Reference