Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] avoid localized output from external commands in a few completion



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




Messages sorted by: Reverse Date, Date, Thread, Author