zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Subject: Re: vcs_info and locales
Date: Sun, 25 Apr 2010 16:09:31 +0200	[thread overview]
Message-ID: <8739yjoc84.fsf@ft.bewatermyfriend.org> (raw)
In-Reply-To: <20100425131944.GA55789@redoubt.spodhuis.org> (Phil Pennock's message of "Sun, 25 Apr 2010 06:19:44 -0700")

Phil Pennock wrote:
> On 2010-04-25 at 10:38 +0200, Frank Terbeck wrote:
>> Anyway, could you try the following patch for the locale problem? I
>> think it should solve the issue once and for all.
>
> I have one concern, which leads to the question: is it really necessary
> to set LC_ALL instead of LC_MESSAGES?
>
> The main problem is that when you override LC_CTYPE to C, you lose any
> potential UTF-8 support, unless the tool just passes through the binary
> data.
>
> I think the safest algorithm is not to set LC_ALL but instead:
>  * set LC_MESSAGES=C
>  * if LC_ALL is set and is not C, set LANG=$LC_ALL, unset LC_ALL
>
> Make sense?

Probably true. Although, I'd expect programs you can use for scripting
to use untempered byte sequences. But then, where is the boundary for
programs that are used for scripting and pure user-interface programs...
`svn info' is probably a pretty blurry example already.

I'm not an expert but I think your proposal is sound.  Here's a patch
that does exactly that.

It would be good if François could test whether this works for him.

Regards, Frank

---------- >8 ----------
>From 95f005d1d8a5791eb8937b745adbd65ac62828f4 Mon Sep 17 00:00:00 2001
From: Frank Terbeck <ft@bewatermyfriend.org>
Date: Sun, 25 Apr 2010 16:00:09 +0200
Subject: PATCH: vcs_info: Avoid locale related problems
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is to avoid problems with output from external commands with non-C
locales as reported by François Gannaz in workers-27900.
---
 Functions/VCS_Info/vcs_info |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index a9e65e1..6585e7a 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -47,11 +47,16 @@ vcs_info () {
     local pat
     local -i found
     local -a enabled disabled dps
-    local -x usercontext vcs rrn
+    local -x usercontext vcs rrn LC_MESSAGES
     local -ix maxexports
     local -ax msgs
     local -Ax vcs_comm
 
+    LC_MESSAGES=C
+    if [[ -n ${LC_ALL} ]]; then
+        local -x LANG LC_ALL
+        LANG=${LC_ALL}
+    fi
     vcs='-init-'; rrn='-all-'
     usercontext=${1:-default}
 
-- 
1.7.0


  reply	other threads:[~2010-04-25 14:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-24 21:40 François Gannaz
2010-04-25  8:38 ` Frank Terbeck
2010-04-25 10:36   ` François Gannaz
2010-04-25 13:19   ` Phil Pennock
2010-04-25 14:09     ` Frank Terbeck [this message]
2010-04-25 14:29       ` Frank Terbeck
2010-05-19 10:07       ` Richard Hartmann
2010-05-19 11:50         ` François Gannaz
2010-05-19 12:03           ` Richard Hartmann
2010-04-25 19:09     ` François Gannaz
2010-04-26  0:29       ` Phil Pennock
2010-04-26  6:36         ` Frank Terbeck
2010-04-26  8:56           ` François Gannaz
2010-04-26 19:07             ` Frank Terbeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8739yjoc84.fsf@ft.bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).