FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

SC3003 · koalaman/shellcheck Wiki · GitHub

SC3003 · koalaman/shellcheck Wiki · GitHub
Skip to content

Navigation Menu

Kevin Turner edited this page Mar 30, 2026 · 4 revisions

In POSIX sh, $'..' is undefined.

Problematic code:

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

Correct code:

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

or

#!/bin/sh
# Trailing linefeed added literally
IFS="$(printf ' \t')
"

or

#!/bin/bash
# Bash supports this
IFS=$' \t\n'

Rationale:

ANSI-C quoting, $'..', is a bash extension, which is not supported by POSIX 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.

Exceptions:

None.

Versions:

POSIX.1-2024 introduced Dollar-Single-Quotes. This rule was last applicable to POSIX.1-2017.

Related resources:

Wiki pages Pages 545

Clone this wiki locally

Footer

© 2026 GitHub, Inc.

Back | FazBrowse Home | New Git URL