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 false positive on ash (In dash, read -t is not supported) #3099

Open
2 tasks done
felipecrs opened this issue Dec 11, 2024 · 0 comments
Open
2 tasks done

SC3045 false positive on ash (In dash, read -t is not supported) #3099

felipecrs opened this issue Dec 11, 2024 · 0 comments

Comments

@felipecrs
Copy link
Contributor

felipecrs commented Dec 11, 2024

For bugs

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

# shellcheck shell=ash

read -r -t 1 -n 1 keypress

echo "$keypress"

Here's what shellcheck currently says:

read -r -t 1 -n 1 keypress
        ^-- [SC3045](https://www.shellcheck.net/wiki/SC3045) (error): In dash, read -t is not supported.

Here's what I wanted or expected to see:

read -t is supported by both ASH and Busybox, I can confirm with:

$ docker run --rm -it alpine ash -c 'read -r -t 1 -n 1 keypress && printf "\nKeypress: %s\n" "$keypress"'
s
Keypress: s
$ echo $?
0

$ docker run --rm -it alpine ash -c 'read -r -t 1 -n 1 keypress && printf "\nKeypress: %s\n" "$keypress"'
$ echo $?
1
$ docker run --rm -it busybox sh -c 'read -r -t 1 -n 1 keypress && printf "\nKeypress: %s\n" "$keypress"'
s
Keypress: s
$ echo $?
0

$ docker run --rm -it busybox sh -c 'read -r -t 1 -n 1 keypress && printf "\nKeypress: %s\n" "$keypress"'
$ echo $?
1
@felipecrs felipecrs changed the title SC3045 false positive: In dash, read -t is not supported SC3045 false positive on ash (In dash, read -t is not supported) Dec 11, 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

1 participant