Skip to content

read-without-raw

Shellsuspiciousno fixdefault: offshell/shellcheck

Reports a read without -r.

Without -r, read treats a backslash in the input as an escape: it removes it and joins the next line. Paths and text with a backslash come out wrong.

To fix, write read -r.

Reported
...
echo "$(date) now" $x
echo "$(date)s"
read line
read -r line
read -p "x" -r line
...
shell:
lint:
rules:
read-without-raw: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line read-without-raw in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
shellcheck SC2162 full