-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC3059
Alwin Wang edited this page Jul 30, 2025
·
3 revisions
(or "In dash, ... is not supported." when using dash
)
#!/bin/sh
x='test'
echo "${x^^[t]}"
The easiest solution is to switch to a shell that does support name matching prefixes, like bash
:
#!/bin/bash
x='test'
echo "${x^^[t]}"
Alternatively, use external tools like tr
for case conversion
#!/bin/sh
x='test'
echo "$x" | tr 't' 'T'
Case modification in parameter expansion (e.g., ${x^^}
, ${x,,}
, ${x^}
, ${x,[pattern]}
) is a bash and ksh extension. dash and POSIX sh do not support it.
If you only intend to target shells that supports this feature, you can change the shebang to a shell that guarantees support, or ignore this warning.
You can use # shellcheck disable=SC3000-SC4000
to ignore all such compatibility
warnings.
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
- https://github.com/sbaudoin/sonar-shellcheck/blob/master/src/main/scripts/build_checks.yml