Bash manual mentions that Locale-Specific Translation

A double-quoted string preceded by a dollar sign (‘$’) will cause the string to be translated according to the current locale. If the current locale is C or POSIX, the dollar sign is ignored. If the string is translated and replaced, the replacement is double-quoted.

Does this way of specifying a string literal exist in C language or some C library?

Does bash imitate this way from C?


$"..." is Bash's way of accessing GNU gettext translations. In C code it would generally be gettext("...") or _("..."). Bash uses the system's default message catalog; a C application could also load up any catalogs it wanted to use.

The $" syntax is a Bash extension to resemble the existing parameter expansion syntax, and I suppose particularly the $' ANSI-C quoting it took from ksh and which may make it into POSIX in future. The C language does not support or have a parallel for the syntax itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.