Skip to content

Files

Latest commit

 

History

History
27 lines (17 loc) · 735 Bytes

SC2256.md

File metadata and controls

27 lines (17 loc) · 735 Bytes

Pattern: Translated string is the name of variable

Issue: -

Description

$".." is a localized string, for example, echo $"Hello $USER" along with the proper translation files can be used to have the script say "Bonjour, youruser" in French locales.

In this case, ShellCheck found a localized string whose contents is also the name of a variable. This could have happened because the user wanted a far more common quoted substitution, e.g. "$var", but accidentally switched the leading $ and ".

Example of incorrect code:

var="foo"
echo $"var"

Example of correct code:

var="foo"
echo "$var"

Further Reading