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

[SC3045] read -d is POSIX.1-2024 compliant #3062

Open
3 tasks done
JP-Ellis opened this issue Sep 23, 2024 · 1 comment
Open
3 tasks done

[SC3045] read -d is POSIX.1-2024 compliant #3062

JP-Ellis opened this issue Sep 23, 2024 · 1 comment

Comments

@JP-Ellis
Copy link

For bugs

  • Rule Id: SC3045
  • 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

For new checks and feature suggestions

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

#!/bin/sh

read -r -d ':' foo

Here's what shellcheck currently says:

Line 3	SC3045: In POSIX sh, read -d is undefined.

Here's what I wanted or expected to see:

I believe this is a false-positive, as the POSIX description for read shows that it does support -d. See the specification here and the relevant quote part below.

NAME

read — read from standard input into shell variables

SYNOPSIS

read [-r] [-d delim] var...

OPTIONS

The read utility shall conform to XBD 12.2 Utility Syntax Guidelines .

The following options shall be supported:

  • -d delim

    If delim consists of one single-byte character, that byte shall be used as the logical line delimiter. If delim is the null string, the logical line delimiter shall be the null byte. Otherwise, the behavior is unspecified.

  • -r

    Do not treat a character in any special way. Consider each to be part of the input line.

The support for -d in POSIX appears to be relatively recent though, as the previous edition do indeed omit it the option.

Perhaps I missed a way of specifying the POSIX version?

@tgross35
Copy link

This also has a pretty notable effect on SC2044, I am very much looking forward to having this flag.

Tested with Alpine and ash (busybox) supports -d already but unfortunately, Debian dash does not yet seem to support it yet. I requested via https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087810.

(#2555 is another issue relating to posix 2024)

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

2 participants