On Tue, Jun 13, 2017 at 08:06:50PM -0400, Chet Ramey wrote:
> That works with Mac OS X, where the output of locale(1) is a series of
> shell assignment statements with quoted values; your mileage may vary, of
> course.

POSIX <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html>
defines the format.  LANG is unquoted, and other values are either
quoted or unquoted depending on whether they are explicitly set in the
environment, or derived.

Sounds pretty unsafe to eval, to me.

imadev:~$ locale
LANG=en_US.iso88591
LC_CTYPE="en_US.iso88591"
LC_COLLATE="en_US.iso88591"
LC_MONETARY="en_US.iso88591"
LC_NUMERIC="en_US.iso88591"
LC_TIME=POSIX
LC_MESSAGES="en_US.iso88591"
LC_ALL=
imadev:~$ LC_CTYPE='$(date +%Y%m%d)' locale

Warning! One or more of your selected locales are not available.
Please invoke the commands "locale" and "locale -a" to verify your
selections and the available locales.

Continuing processing using the "C" locale.

LANG=en_US.iso88591
LC_CTYPE=$(date +%Y%m%d)
LC_COLLATE="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME=POSIX
LC_MESSAGES="C"
LC_ALL=

Reply via email to