From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27625 invoked by alias); 26 Dec 2017 10:52:59 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42175 Received: (qmail 14808 invoked by uid 1010); 26 Dec 2017 10:52:59 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-mqugw.biglobe.ne.jp by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(133.208.100.3):SA:0(-2.6/5.0):. Processed in 1.575982 secs); 26 Dec 2017 10:52:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: takimoto-j@kba.biglobe.ne.jp X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Biglobe-Sender: From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] avoid localized output from external commands in a few completion Date: Tue, 26 Dec 2017 19:52:22 +0900 References: <42959CB1-DB49-474F-86DA-DD4C08D1CE43@kba.biglobe.ne.jp> <1514251193.2800192.1215805184.324D9E4C@webmail.messagingengine.com> <19CB3093-E02F-48F1-AE9D-8A446FED7540@kba.biglobe.ne.jp> <970D7BE1-CE5A-4C9F-AFCF-9C272DC334AE@kba.biglobe.ne.jp> To: zsh-workers@zsh.org In-Reply-To: <970D7BE1-CE5A-4C9F-AFCF-9C272DC334AE@kba.biglobe.ne.jp> Message-Id: <5B098C2B-6E8B-4E69-80BB-96465CFBE8EE@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3273) X-Biglobe-Spnum: 60741 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=3DC 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=3D"${name//[^a-zA-Z0-9_]/_}" =20 if (( ! ${(P)+name} )); then - local iopts sopts pattern tmpo dir cur cache + local iopts sopts lflag pattern tmpo dir cur cache typeset -Ua lopts =20 cache=3D() @@ -55,7 +55,12 @@ if (( long )); then =20 iopts=3D() sopts=3D() - while [[ "$1" =3D -[is]* ]]; do + while [[ "$1" =3D -[lis]* ]]; do + if [[ "$1" =3D -l ]]; then + lflag=3D'-l' + shift + continue + fi if [[ "$1" =3D -??* ]]; then tmp=3D"${1[3,-1]}" cur=3D1 @@ -88,7 +93,8 @@ if (( long )); then # option up to the end. =20 tmp=3D() - _call_program options ${~words[1]} --help 2>&1 | while IFS=3D read = -r opt; do + _call_program $lflag options ${~words[1]} --help 2>&1 | + while IFS=3D 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 =20 -local curcontext=3D"${curcontext}" tmp err_fd=3D-1 +local curcontext=3D"${curcontext}" tmp err_fd=3D-1 = clocale=3D'_comp_locale;' local -a prefix =20 if [[ "$1" =3D -p ]]; then @@ -10,6 +10,9 @@ if [[ "$1" =3D -p ]]; then zstyle -t ":completion:${curcontext}:${1}" gain-privileges && prefix=3D( $_comp_priv_prefix ) fi +elif [[ "$1" =3D -l ]]; then + shift + clocale=3D'' fi =20 if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]] @@ -21,12 +24,12 @@ fi =20 if zstyle -s ":completion:${curcontext}:${1}" command tmp; then if [[ "$tmp" =3D -* ]]; 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 =20 } always {