Grische
2025-07-30 15:57:12 +02:00
parent 4d27a01f84
commit c4f51fcdce

29
SC3061.md Normal file

@@ -0,0 +1,29 @@
## `read` without a variable is undefined.
### Problematic code:
```sh
while read -r;
do
echo "line: ${REPLY}"
done < foolist
```
### Correct code:
Add a variable to read and use it later on:
```sh
while read -r foo;
do
echo "line: ${foo}"
done < foolist
```
### Rationale:
This behavior is not allowed [in POSIX](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html).
### Exceptions:
None. This warning is not emitted in `ksh` or `bash` where read can be used without an argument.