Skip to content

Feature request: Allow directives in trailing comments #1295

@reidpr

Description

@reidpr

I would like to be able to specify directives on the same line as the command in order to save vertical space and reduce clutter.

This is similar to, but not a duplicate of, #1267.

(Thanks for your hard work on ShellCheck. I am finding tons of bugs in my code with it.)

For new checks and feature suggestions

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

#!/bin/bash

CH_RUN_FILE="$(command -v ch-run)"       # shellcheck disable=SC2034
CH_LIBEXEC="$(ch-build --libexec-path)"  # shellcheck disable=SC2034

Here's what shellcheck currently says:

(shellcheck.net as of right now.)

$ shellcheck myscript
 
Line 3:
CH_RUN_FILE="$(command -v ch-run)"       # shellcheck disable=SC2034
^-- SC2034: CH_RUN_FILE appears unused. Verify use (or export if used externally).
                                         ^-- SC1126: Place shellcheck directives before commands, not after.
 
Line 4:
CH_LIBEXEC="$(ch-build --libexec-path)"  # shellcheck disable=SC2034
^-- SC2034: CH_LIBEXEC appears unused. Verify use (or export if used externally).
                                         ^-- SC1126: Place shellcheck directives before commands, not after.

Here's what I wanted or expected to see:

$ shellcheck myscript
No issues detected!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions