Can anyone explain what is the difference between
echo $"Starting $CMD"
and
echo "String $CMD"
They seem to look the same.
Can anyone explain what is the difference between
echo $"Starting $CMD"
and
echo "String $CMD"
They seem to look the same.
Look up the
QUOTING
section of thebash
man page:And note the follow description double quoted strings preceded by
$
($"string"
):$""
is a form of quoting that is used for language translation. If you invoke bash with the-D
flag it will print out all such strings. When the locale isC
orPOSIX
, this form of quotation doesn't do anything.These strings are used by
gettext
to look up appropriate translations. For example, if your script has the string$"Hello, World"
and you have properly installed MO files for translating that string into, say, French, you could execute your script this way:and expect all instances of
$"Hello, World"
to be output as Bonjour, Tout le Monde (assuming that is what is actually in your translation file).Translation is not magic or automatic, so you must provide the translation engine with whatever translation strings it doesn't already have.
(PS - the guide I linked to does mention this security bug, but you may miss it if you skim, so I highlight it again here.)