Skip to content

Feature Request: Warn about trailing backslashes in comments (similar to SC2215) #2132

@schaetzc

Description

@schaetzc

For new checks and feature suggestions

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

In below scripts a part of a multi-line command was commented out. However, the comment also disabled a backslash at the end of the line and therefore broke the multi-line command into two commands by accident.

#!/bin/bash
sed -i \
  -e s/a/b/ \
  # -e s/x/y/ \
  /path/to/file

or

#!/bin/bash
sed -i -e s/a/b/ # -e s/x/y/ \
/path/to/file

Here's what shellcheck currently says:

No issues detected!

Here's what I wanted or expected to see:

It would be very nice if shellcheck gave a warning about trailing backslashes in comments. The warning could be similar to SC2215. Alternatively, SC2215 could be extended by these kind of mistakes.

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