From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19426 invoked by alias); 27 Dec 2017 11:51:47 -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: 42177 Received: (qmail 16095 invoked by uid 1010); 27 Dec 2017 11:51:47 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-expgw.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.98.3):SA:0(-1.9/5.0):. Processed in 12.253956 secs); 27 Dec 2017 11:51:47 -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=-1.9 required=5.0 tests=BAYES_00,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: Wed, 27 Dec 2017 20:51:30 +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> <5B098C2B-6E8B-4E69-80BB-96465CFBE8EE@kba.biglobe.ne.jp> To: zsh-workers@zsh.org In-Reply-To: <5B098C2B-6E8B-4E69-80BB-96465CFBE8EE@kba.biglobe.ne.jp> Message-Id: X-Mailer: Apple Mail (2.3273) X-Biglobe-Spnum: 63167 > 2017/12/26 19:52, Jun T wrote: >=20 > 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. Here are patches for compsys.yo, _aptitude, _a2ps, _subversion and _tar. diff --git a/Completion/Debian/Command/_aptitude = b/Completion/Debian/Command/_aptitude index b2b54599f..f79a100a8 100644 --- a/Completion/Debian/Command/_aptitude +++ b/Completion/Debian/Command/_aptitude @@ -80,7 +80,7 @@ _arguments -C \ =20 case $state in cmds) - cmds=3D( ${${(M)${(f)"$(LC_ALL=3DC _call_program commands aptitude = -h 2>/dev/null)"}:# [^- ][^ ]## *}/(#b) ([^ ]##) ##(- )#([^- = ]*)/$match[1]:$match[3]:l}) + cmds=3D( ${${(M)${(f)"$(_call_program commands aptitude -h = 2>/dev/null)"}:# [^- ][^ ]## *}/(#b) ([^ ]##) ##(- )#([^- = ]*)/$match[1]:$match[3]:l}) =20 _describe -t commands 'aptitude command' cmds && ret=3D0 ;; diff --git a/Completion/Unix/Command/_a2ps = b/Completion/Unix/Command/_a2ps index c700c205d..aa2f4c3ba 100644 --- a/Completion/Unix/Command/_a2ps +++ b/Completion/Unix/Command/_a2ps @@ -7,7 +7,7 @@ if [[ "$words[1]" !=3D "$_cache_a2ps_cmd" ]]; then =20 _cache_a2ps_cmd=3D"$words[1]" =20 - descr=3D( "${(@)${(f@)$(_call_program features LC_ALL=3DC $words[1] = --list=3Dfeatures)// + descr=3D( "${(@)${(f@)$(_call_program features $words[1] = --list=3Dfeatures)// / }:#}" ) =20 _cache_a2ps_values=3D( diff --git a/Completion/Unix/Command/_subversion = b/Completion/Unix/Command/_subversion index b4ccccfae..6a35e9947 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -34,7 +34,7 @@ _svn () { typeset -gHA _svn_cmds if _cache_invalid svn-cmds || ! _retrieve_cache svn-cmds; then _svn_cmds=3D( - ${=3D${(f)${${"$(_comp_locale; _call_program commands svn = help)"#l#*Available subcommands:}%%Subversion is a = tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, = ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:} + ${=3D${(f)${${"$(_call_program commands svn help)"#l#*Available = subcommands:}%%Subversion is a = tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, = ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:} ) if (( $? =3D=3D 0 )); then _store_cache svn-cmds _svn_cmds @@ -60,14 +60,14 @@ _svn () { if _cache_invalid svn-${cmd}-usage || \ ! _retrieve_cache svn-${cmd}-usage; then - usage=3D${${(M)${(f)"$(_comp_locale; _call_program options svn = help $cmd)"}:#usage:*}#usage:*$cmd] } + usage=3D${${(M)${(f)"$(_call_program options svn help = $cmd)"}:#usage:*}#usage:*$cmd] } _store_cache svn-${cmd}-usage usage fi if _cache_invalid svn-${cmd}-usage || \ ! _retrieve_cache svn-${cmd}-args; then args=3D( - ${=3D${${${(M)${(f)"$(_comp_locale; _call_program options = svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ = (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) = \[--([a-z-]##)\](:arg:)#/(--$match[3])$match[1]$match[2]$match[4] = ($match[1]$match[2])--$match[3]$match[4]} + ${=3D${${${(M)${(f)"$(_call_program options svn help = $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ = (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) = \[--([a-z-]##)\](:arg:)#/(--$match[3])$match[1]$match[2]$match[4] = ($match[1]$match[2])--$match[3]$match[4]} ) while (( idx=3D$args[(I)*--accept:arg:] )); do args[(I)*--accept:arg:]=3D( --accept'=3D:automatic conflict = resolution action:((working\:working base\:base '"`for i j in p postpone = mc mine-conflict tc theirs-conflict mf mine-full tf theirs-full e edit l = launch; do print -rn $i\\\\:$j $j\\\\:$j ""; done `"'))' ) @@ -227,7 +227,7 @@ _svnadmin () { if [[ -n $state ]] && (( ! $+_svnadmin_cmds )); then typeset -gHA _svnadmin_cmds _svnadmin_cmds=3D( - ${=3D${(f)${${"$(_comp_locale; _call_program commands svnadmin = help)"#l#*Available = subcommands:}}}/(#s)[[:space:]]#(#b)([-a-z]##)[[:space:]]#(\([a-z, = ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:} + ${=3D${(f)${${"$(_call_program commands svnadmin = help)"#l#*Available = subcommands:}}}/(#s)[[:space:]]#(#b)([-a-z]##)[[:space:]]#(\([a-z, = ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:} ) fi =20 @@ -242,9 +242,9 @@ _svnadmin () { if (( $#cmd )); then curcontext=3D"${curcontext%:*:*}:svnadmin-${cmd}:" =20 - usage=3D${${(M)${(f)"$(_comp_locale; _call_program options = svnadmin help $cmd)"}:#$cmd: usage:*}#$cmd: usage: svnadmin $cmd } + usage=3D${${(M)${(f)"$(_call_program options svnadmin help = $cmd)"}:#$cmd: usage:*}#$cmd: usage: svnadmin $cmd } args=3D( - ${=3D${${${(M)${(f)"$(_comp_locale; _call_program options = svnadmin help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ = (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) = \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] = (-$match[1])--$match[2]$match[3]} + ${=3D${${${(M)${(f)"$(_call_program options svnadmin help = $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ = (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) = \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] = (-$match[1])--$match[2]$match[3]} ) # All options get {-x+,--long-x=3D} args=3D( ${args/(#b)(--[A-Za-z0-9-]##):arg:/$match[1]=3D:arg:} = ) @@ -429,7 +429,7 @@ _svn_props() { _svn_changelists() { local cls =20 - cls=3D( ${${${(M)${(f)"$(_comp_locale; _call_program changelists svn = status 2>/dev/null)"}:#--- Changelist*}%??}##*\'} ) + cls=3D( ${${${(M)${(f)"$(_call_program changelists svn status = 2>/dev/null)"}:#--- Changelist*}%??}##*\'} ) compadd "$@" -a cls && return 0 } =20 diff --git a/Completion/Unix/Command/_tar b/Completion/Unix/Command/_tar index ecf02fd83..cff50562e 100644 --- a/Completion/Unix/Command/_tar +++ b/Completion/Unix/Command/_tar @@ -99,7 +99,7 @@ if [[ "$PREFIX" =3D --* ]]; then =20 # ...long options after `--'. =20 - _arguments -- '--owner=3D*:user:_users' \ + _arguments -- -l '--owner=3D*:user:_users' \ '--group=3D*:group:_groups' \ '--atime-preserve*::method:(replace system)' \ '--*-script=3DNAME:script file:_files' \ diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 36afd7305..a0e99f2e4 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -3596,7 +3596,8 @@ findex(_arguments) redef(SPACES)(0)(tt(ifztexi(NOTRANS(@ @ @ @ @ @ @ @ @ @ @ ))ifnztexi( = ))) xitem(tt(_arguments )[ tt(-nswWCRS) ] [ tt(-A) var(pat) ] [ tt(-O) = var(name) ] [ tt(-M) var(matchspec) ]) xitem(SPACES()[ tt(:) ] var(spec) ...) -item(tt(_arguments) [ var(opt) ... ] tt(-)tt(-) [ tt(-i) var(pats) ] [ = tt(-s) var(pair) ] [ var(helpspec) ... ])( +xitem(tt(_arguments )[ var(opt) ... ] tt(-)tt(-) [ tt(-l) ] [ tt(-i) = var(pats) ] [ tt(-s) var(pair) ]) +item(SPACES()[ var(helpspec) ...])( This function can be used to give a complete specification for = completion for a command whose arguments follow standard UNIX option and argument conventions. @@ -4139,6 +4140,12 @@ pattern and the var(action) will be used only = directly after the `tt(=3D)', not in the next word. This is the behaviour of a normal specification defined with the form `tt(=3D-)'. =20 +By default, the command (with the option `tt(--help)') is run after +resetting all the locale categories (except for tt(LC_CTYPE)) to = `tt(C)'. +If the localized help output is known to work, the option `tt(-l)' can +be specified after the `tt(_arguments -)tt(-)' so that the command is +run in the current locale. + The `tt(_arguments -)tt(-)' can be followed by the option `tt(-i) var(patterns)' to give patterns for options which are not to be completed. The patterns can be given as the name of an array parameter @@ -4230,7 +4237,7 @@ The return status of tt(_call_function) itself is = zero if the function var(name) exists and was called and non-zero otherwise. ) findex(_call_program) -item(tt(_call_program) [ tt(-p) ] var(tag) var(string) ...)( +item(tt(_call_program) [ tt(-l) ] [ tt(-p) ] var(tag) var(string) ...)( This function provides a mechanism for the user to override the use of = an external command. It looks up the tt(command) style with the supplied var(tag). If the style is set, its value is used as the command to @@ -4239,6 +4246,11 @@ style if set, are concatenated with spaces = between them and the resulting string is evaluated. The return status is the return status of the = command called. =20 +By default, the command is run in an environment where all the locale +categories (except for tt(LC_CTYPE)) are reset to `tt(C)' by calling = the +utility function tt(_comp_locale) (see below). If the option `tt(-l)' = is +given, the command is run with the current locale. + If the option `tt(-p)' is supplied it indicates that the command output is influenced by the permissions it is run with. If the tt(gain-privileges) style is set to true, tt(_call_program) will make @@ -4299,6 +4311,18 @@ This function completes words that are valid at = command position: names of aliases, builtins, hashed commands, functions, and so on. With the = tt(-e) flag, only hashed commands are completed. The tt(-) flag is ignored. ) +findex(_comp_locale) +item(tt(_comp_locale))( +This function resets all the locale categories other than tt(LC_CTYPE) = to +`tt(C)' so that the output from external commands can be easily = analyzed by +the completion system. tt(LC_CTYPE) retains the current value (either +explicitly set or inherited from tt(LC_ALL) or tt(LANG)), ensuring that +non-ASCII characters in file names are still handled properly. + +This function should normally be run only in a subshell, because the = new +locale is exported to the environment. Typical usage would be +`tt($LPAR()_comp_locale; )var(command) ...tt(RPAR())'. +) findex(_completers) item(tt(_completers) [ tt(-p) ])( This function completes names of completers.