zsh-workers
 help / color / mirror / code / Atom feed
From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: [PATCH] avoid localized output from external commands in a few completion
Date: Tue, 26 Dec 2017 08:40:06 +0900	[thread overview]
Message-ID: <42959CB1-DB49-474F-86DA-DD4C08D1CE43@kba.biglobe.ne.jp> (raw)

In some recent Linux distributions, output from commands
like 'nm --help' is localized and can't be analyzed correctly
by completion scripts. We need to reset LC_MESSAGES.


diff --git a/Completion/Linux/Command/_lsblk b/Completion/Linux/Command/_lsblk
index f37305445..f6bf9250d 100644
--- a/Completion/Linux/Command/_lsblk
+++ b/Completion/Linux/Command/_lsblk
@@ -44,7 +44,7 @@ case $state in
   ;|
   column*)
     values=(
-      ${${${${(f)"$(_call_program columns lsblk -h)"}[(r)Available*,-3]## #}[2,-1]//:/\\:}/  /:}
+      ${${${${(f)"$(_call_program columns LC_MESSAGES=C lsblk -h)"}[(r)Available*,-3]## #}[2,-1]//:/\\:}/  /:}
     )
     _describe -t fields column values -M 'm:{a-z}={A-Z}' $suf -F dedup && ret=0
   ;;
diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm
index 146a69e8a..b195a66ef 100644
--- a/Completion/Unix/Command/_nm
+++ b/Completion/Unix/Command/_nm
@@ -64,7 +64,7 @@ if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfu
 	'--plugin[load specified plugin]:plugin'
 	'--special-syms[include special symbols in the output]'
 	'--synthetic[display synthetic symbols as well]'
-	"--target=[target object format]:targets:(${${(@M)${(f)$(_call_program targets nm --help)}:#*supported targets:*}##*: })"
+	"--target=[target object format]:targets:(${${(@M)${(f)$(_call_program targets LC_MESSAGES=C nm --help)}:#*supported targets:*}##*: })"
 	'--with-symbol-versions[display version strings after symbol names]'
       )
     ;;
diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump
index e012b4cbc..9744d3177 100644
--- a/Completion/Unix/Command/_objdump
+++ b/Completion/Unix/Command/_objdump
@@ -92,13 +92,13 @@ case "$state" in
     _values -s , "dwarf section" rawline decodedline info abbrev pubnames aranges macro frames frames-interp str loc Ranges pubtypes gdb_index trace_info trace_abbrev trace_aranges addr cu_index
   ;;
   bfdname)
-    _values "object format" "${(z)${(@M)${(f)$(_call_program targets objdump --help)}##* supported targets:*}##*: }"
+    _values "object format" "${(z)${(@M)${(f)$(_call_program targets LC_MESSAGES=C objdump --help)}##* supported targets:*}##*: }"
   ;;
   machine)
-    _values "machine architecture" "${(@)${(z)${(@M)${(f)$(_call_program targets objdump --help)}##* supported architectures:*}##*: }//:/\\:}"
+    _values "machine architecture" "${(@)${(z)${(@M)${(f)$(_call_program targets LC_MESSAGES=C objdump --help)}##* supported architectures:*}##*: }//:/\\:}"
   ;;
   disassembler_options)
-    _values -s , "disassembler options" "${(@)${(@)${(@M)${(f)${(ps.-M switch.)$(_call_program targets objdump --help)}[2]}:#  [^ ]*}#  }%% *}"
+    _values -s , "disassembler options" "${(@)${(@)${(@M)${(f)${(ps.-M switch.)$(_call_program targets LC_MESSAGES=C objdump --help)}[2]}:#  [^ ]*}#  }%% *}"
   ;;
 esac
 
diff --git a/Completion/Unix/Command/_strip b/Completion/Unix/Command/_strip
index 0703c50e4..552c2839c 100644
--- a/Completion/Unix/Command/_strip
+++ b/Completion/Unix/Command/_strip
@@ -54,7 +54,7 @@ case $state in
     local expl
     declare -a bfdnames
 
-    bfdnames=(${=${(M)${(f)"$(_call_program bfdnames strip --help)"}:#strip: supported targets: *}#strip: supported targets: })
+    bfdnames=(${=${(M)${(f)"$(_call_program bfdnames LC_MESSAGES=C strip --help)"}:#strip: supported targets: *}#strip: supported targets: })
     _describe -t bfdnames 'bfd name' bfdnames && ret=0
     ;;
 esac



             reply	other threads:[~2017-12-26  0:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-25 23:40 Jun T. [this message]
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
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=42959CB1-DB49-474F-86DA-DD4C08D1CE43@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).