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

Disable directive ignored in array? #3013

Open
1 of 2 tasks
Roy-Orbison opened this issue Jul 1, 2024 · 0 comments
Open
1 of 2 tasks

Disable directive ignored in array? #3013

Roy-Orbison opened this issue Jul 1, 2024 · 0 comments

Comments

@Roy-Orbison
Copy link

For bugs

  • Rule Id (if any, e.g. SC1000): SC2054, SC2206, SC2086
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

Here's a snippet or screenshot that shows the problem:

#!/bin/bash

g='Pictures/*'
a=(
        -ld
        # shellcheck disable=SC2206,SC2086
        $g
)
ls "${a[@]}"

Here's what shellcheck currently says:

Line 4	SC2054: Use spaces, not commas, to separate array elements.
Line 7	SC2206: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.

Here's what I wanted or expected to see:

Nothing. The comma is in a comment, so isn't used to separate array elements. The disable directive comment should prevent the other issues, but is ignored in the array.

Context

Using an array for args because bash does not support comments interspersed with line continuations, without using hacks. So I can't write:

command \
    --opt1 \
    --opt2 \
    # shellcheck disable=SC2086
    $var_that_globs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant