On 08Jul2019 12:30, Jon LaBadie <mut...@jgcomp.com> wrote:
On Mon, Jul 08, 2019 at 05:53:22AM -0500, Peng Yu wrote:
`mutt -D` prints 'charset="iso-8859-1"' when it runs in a
non-interactive bash session scheduled by crontab.

But the same command prints 'charset="utf-8"' when it runs in an
interactive bash session. I suspect that this is affected by an
environment variable.

Does anybody know why there is such a difference?

Processes run by cron do not mimic your login environment.
If you need specific things set that are typically set in
.profile etc., you need to set them in your crontab file
or the executed script.

You can wire basic environment variables into the crontab. The usual example is the MAILTO environment variable or a basic PATH, but you can easily set locale relevant variables as well.

The "locale" command reports the current (computed) locale settings. Here's mine just now:

   % locale
   LANG=en_GB.UTF-8
   LANGUAGE=en_AU:en
   LC_CTYPE=en_GB.UTF-8
   LC_NUMERIC="en_GB.UTF-8"
   LC_TIME="en_GB.UTF-8"
   LC_COLLATE=C
   LC_MONETARY="en_GB.UTF-8"
   LC_MESSAGES="en_GB.UTF-8"
   LC_PAPER="en_GB.UTF-8"
   LC_NAME="en_GB.UTF-8"
   LC_ADDRESS="en_GB.UTF-8"
   LC_TELEPHONE="en_GB.UTF-8"
   LC_MEASUREMENT="en_GB.UTF-8"
   LC_IDENTIFICATION="en_GB.UTF-8"
   LC_ALL=

My only actual environment variables are these:

   LANG=en_GB.UTF-8
   LANGUAGE=en_AU:en
   LC_CTYPE=en_GB.UTF-8

You could put something equivalent in your crontab.

See "man locale" and also the other manual entries referenced in its SEE ALSO section at the bottom.

Cheers,
Cameron Simpson <c...@cskk.id.au>

Reply via email to