Skip to content

Files

Latest commit

 

History

History
31 lines (19 loc) · 747 Bytes

SC1117.md

File metadata and controls

31 lines (19 loc) · 747 Bytes

Pattern: Use of literal backslash in double quoted string

Issue: -

Description

In a double quoted string, you have escaped a character that has no special behavior when escaped. Instead, it's invoking the fallback behavior of being interpreted literally.

Instead of relying on this implicit fallback, you should escape the backslash explicitly. This makes it clear that it's meant to be passed as a literal backslash in the string parameter.

Example of incorrect code:

printf "%s\n" "Hello"

Example of correct code:

printf "%s\\n" "Hello"

or alternatively, with single quotes:

printf '%s\n' "Hello"

Further Reading