Le 24/07/2021 à 20:48, Chet Ramey écrivait :
On 7/24/21 10:35 AM, Jean-Jacques Brucker wrote:

Planning to use the /$"string/" feature in my bash code made me think too much : https://github.com/foopgp/bash-libs/tree/main/i18n


...what I really *love* to see in bash, is a /$'string'/ feature, which doesn't parse any «`» or «$» characters.

So you want a translation feature without any further interpretation? Or
one just without command substitution?

What about an option to enable this variant behavior? What do you think
would be a suitable name?


It'd be perfectly fine if non interpreted locale string was reserved for format string of the built-in printf, and supported positional arguments.

Example:

declare -- str='Hello World!'
declare -i num=42
printf $"string: %1$s, int %2$d\n" "$str" $num


Unchanged gettext string syntax $"string" but without variable and sub-shell expansion, and %n$ positional markers support when it is used as a printf format string.

Would fix the security risks of variable expansion in gettext strings.
Would not overlap $'c-style string' syntax.
Would maintain variable expansion outside the printf format string context to maintain backward compatibility.


--
Léa Gris


Reply via email to