zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] avoid localized output from external commands in a few completion
Date: Tue, 26 Dec 2017 19:52:22 +0900	[thread overview]
Message-ID: <5B098C2B-6E8B-4E69-80BB-96465CFBE8EE@kba.biglobe.ne.jp> (raw)
In-Reply-To: <970D7BE1-CE5A-4C9F-AFCF-9C272DC334AE@kba.biglobe.ne.jp>

With the patch below, both _call_program and '_arguments --' will call
_comp_locale before running the external command. This is disabled
by passing an option '-l' to _call_program or '_arguments --'.

If this is OK, then we can remove LC_ALL=C from _aptitude and _a2ps,
and _comp_locale from _subversion. I will also prepare patches for
compsys.yo.

It seems '_arguments --' (or _gnu_generic) is used only in _tar.
I think we can use '_arguments -- -l' here, because non-English
help output is handled rather well by '_arguments --' (at least
as well as the English help).


diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index d2c0d33de..136dd5826 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -43,7 +43,7 @@ if (( long )); then
   name="${name//[^a-zA-Z0-9_]/_}"
 
   if (( ! ${(P)+name} )); then
-    local iopts sopts pattern tmpo dir cur cache
+    local iopts sopts lflag pattern tmpo dir cur cache
     typeset -Ua lopts
 
     cache=()
@@ -55,7 +55,12 @@ if (( long )); then
 
     iopts=()
     sopts=()
-    while [[ "$1" = -[is]* ]]; do
+    while [[ "$1" = -[lis]* ]]; do
+      if [[ "$1" = -l ]]; then
+	lflag='-l'
+	shift
+	continue
+      fi
       if [[ "$1" = -??* ]]; then
         tmp="${1[3,-1]}"
         cur=1
@@ -88,7 +93,8 @@ if (( long )); then
     # option up to the end.
 
    tmp=()
-   _call_program options ${~words[1]} --help 2>&1 | while IFS= read -r opt; do
+   _call_program $lflag options ${~words[1]} --help 2>&1 |
+     while IFS= read -r opt; do
      if (( ${#tmp} )); then
        # Previous line had no comment.  Is the current one suitable?
        # It's hard to be sure, but if it there was nothing on the
diff --git a/Completion/Base/Utility/_call_program b/Completion/Base/Utility/_call_program
index 9a44f2d8e..73f3ef6d2 100644
--- a/Completion/Base/Utility/_call_program
+++ b/Completion/Base/Utility/_call_program
@@ -1,6 +1,6 @@
 #autoload +X
 
-local curcontext="${curcontext}" tmp err_fd=-1
+local curcontext="${curcontext}" tmp err_fd=-1 clocale='_comp_locale;'
 local -a prefix
 
 if [[ "$1" = -p ]]; then
@@ -10,6 +10,9 @@ if [[ "$1" = -p ]]; then
     zstyle -t ":completion:${curcontext}:${1}" gain-privileges &&
 	prefix=( $_comp_priv_prefix )
   fi
+elif [[ "$1" = -l ]]; then
+  shift
+  clocale=''
 fi
 
 if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]]
@@ -21,12 +24,12 @@ fi
 
 if zstyle -s ":completion:${curcontext}:${1}" command tmp; then
   if [[ "$tmp" = -* ]]; then
-    eval "$tmp[2,-1]" "$argv[2,-1]"
+    eval $clocale "$tmp[2,-1]" "$argv[2,-1]"
   else
-    eval $prefix "$tmp"
+    eval $clocale $prefix "$tmp"
   fi
 else
-  eval $prefix "$argv[2,-1]"
+  eval $clocale $prefix "$argv[2,-1]"
 fi 2>&$err_fd
 
 } always {




  reply	other threads:[~2017-12-26 10:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-25 23:40 Jun T.
2017-12-26  1:04 ` Bart Schaefer
2017-12-26  1:19   ` Daniel Shahaf
2017-12-26  4:47     ` Jun T
2017-12-26  4:59       ` Jun T
2017-12-26 10:52         ` Jun T [this message]
2017-12-27 11:51           ` Jun T
2017-12-27 23:15             ` Daniel Shahaf
2017-12-28  2:54               ` Jun T
2017-12-26  5:24       ` Daniel Shahaf

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=5B098C2B-6E8B-4E69-80BB-96465CFBE8EE@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --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).