diff options
author | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2017-12-28 11:35:34 +0900 |
---|---|---|
committer | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2017-12-28 11:35:34 +0900 |
commit | d303dfa7f59aef999c43e2a7a56aac7099e40454 (patch) | |
tree | f0837ee5acf50bc88908b3ed8ca6764cd5210c3c /Completion/Base | |
parent | 24152f766f75bdc0efad109a8a9f8b164008fc1a (diff) | |
download | zsh-d303dfa7f59aef999c43e2a7a56aac7099e40454.tar.gz zsh-d303dfa7f59aef999c43e2a7a56aac7099e40454.tar.xz zsh-d303dfa7f59aef999c43e2a7a56aac7099e40454.zip |
42175 + 42177 + 42178: avoid localized output from external commands
_call_program and '_arguments --' will call _comp_locale before calling external command for easier analysis of the output. This is disabled by passing an option '-l'.
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/Utility/_arguments | 12 | ||||
-rw-r--r-- | Completion/Base/Utility/_call_program | 11 |
2 files changed, 16 insertions, 7 deletions
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 { |