# Enhancement request: please add locale to list of allowed \write18 binaries

David Carlisle d.p.carlisle at gmail.com
Thu Jul 28 09:51:12 CEST 2022

On Thu, 28 Jul 2022 at 06:33, Max Chernoff <mseven at telus.net> wrote:

> (I'm *not* a TeX Live maintainer, just a regular user)
>

same here

> A few general comments here:
>
> 1: "locale" is a POSIX command, so it should work with macOS, BSD, and
> Linux. It will not work with Windows though. There are other commands
> that you can use on Windows to get the current language; however, none
> of them would be safe enough for restricted \write18. It wouldn't be too
> hard to make a "safe" wrapper script for Windows, but this is of course
> extra work.
>

I would think this is a show stopper, also you can already  access the
environment
using kpsewhich

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}

{\catcode\_=12
\input{|kpsewhich -expand-var \$LC_CTYPE}
}

\end{document}

prints en_US.UTF-8 for me.

or more packaged version using texosquery (code here from its manual)

\documentclass{article}
\usepackage{tex-locale}
\begin{document}
Language: \CurrentLocaleLanguageNativeName.
Region: \CurrentLocaleRegionNativeName.
Today: \CurrentLocaleDate. (Compare with \today.)
Time: \CurrentLocaleTime.
Currency Symbol: \CurrentLocaleCurrency
Integer:
\texosqueryfmtnumber{\CurrentLocaleIntegerPattern}{123456}{0}{0}
Decimal:
\texosqueryfmtnumber{\CurrentLocaleDecimalPattern}{123456}{78}{0}
Percentage:
\texosqueryfmtnumber{\CurrentLocalePercentPattern}{0}{65}{0}
Currency:
\texosqueryfmtnumber{\CurrentLocaleCurrencyPattern}{1234567}{0}{0}
\end{document}

producing

Language: English. Region: United Kingdom. Today: 28 July 2022. (Com-
pare with 28th July 2022.) Time: 08:44:23. Currency Symbol: £ Integer:
123,456 Decimal: 123,456.78 Percentage: 65% Currency: £1,234,567.00

Neither require shell escape.

> 2: I don't think that this is a good idea. One of the key features of
> TeX (and LaTeX) is that identical input files should produce identical
> output across all systems. Guessing a default language like this would
> break this guarantee, which is probably ill-advised. I think that a
> better approach would be to issue a warning if a default language isn't
> set. This avoids any issues with system dependency or "hidden" state.
>
>
I agree here, it is the same as other local settings notably paper size.
while a "use local locale" option might be useful, the default shouldn't
be system dependent.

3: This is already (roughly) possible with LuaTeX right now:
>
> Yes as above it's also possible in all engines using restricted shell
escape.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/tex-live/attachments/20220728/01912e27/attachment.html>
`