shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC3045: Inconsistent policy

Open mcandre opened this issue 1 year ago • 0 comments

For bugs

  • Rule Id (if any, e.g. SC1000): SC3045
  • My shellcheck version (shellcheck --version or "online"): 0.10.0
  • [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • [x] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

For new checks and feature suggestions

  • [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
  • [x] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related

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

#!/bin/sh
LF='
'

find "$SOURCE" \
    -name '.DS_Store' -o -name 'Thumbs.db' -prune -o \
    -type f \
    -print |
    sort |
    xargs -n "$FILE_LIMIT" |
    while IFS= read -r "-d${LF}" fs; do
        TARGET="${PREFIX}-${I}"
        mkdir -p "$TARGET"

        for f in $fs; do
            cp "$f" "$TARGET"
        done

        I=$((I+1))
    done

Here's what shellcheck currently says:

    while IFS= read -r "-d${LF}" fs; do
                       ^-------^ SC3045 (warning): In POSIX sh, read -d is undefined.

Here's what I wanted or expected to see:

(No warning should be displayed.)

For comparison, the wiki does not document this flag as being non-POSIX compliant:

https://www.shellcheck.net/wiki/SC3045

In fact, the POSIX standard formally accepts -d:

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/read.html

mcandre avatar Sep 17 '24 03:09 mcandre