-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC3003
Joachim Ansorg edited this page Nov 12, 2021
·
3 revisions
#!/bin/sh
IFS=$' \t\n'
#!/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'
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.
None.
- StackOverflow: Why does my bash code fail when I run it with sh?