Skip to content

Files

Latest commit

 

History

History
30 lines (19 loc) · 782 Bytes

SC3003.md

File metadata and controls

30 lines (19 loc) · 782 Bytes

Pattern: Use of undefined $'..'

Issue: -

Description

You are using the interpolated string Bashism $'..' in a script that declares itself as POSIX sh (e.g. via #!/bin/sh).

To ensure the script runs correctly on other systems, either switch to Bash, or rewrite it in a POSIX compatible way.

This can generally done via printf as in the example. Be careful about strings with trailing linefeeds, as a $(command substitution) will strip them.

Example of incorrect code:

#!/bin/sh
IFS=$' \t\n'

Example of correct code:

#!/bin/sh
# Note: \n can not be last, or it will be stripped by $()
IFS=$(printf ' \n\t')

Further Reading