zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: Zsh workers <zsh-workers@zsh.org>
Subject: [PATCH] Completion: Misc. _call_program fixes
Date: Tue, 12 Jun 2018 20:56:11 -0500	[thread overview]
Message-ID: <A343459B-03F2-4DD9-8527-D55245F4A5EA@dana.is> (raw)

Hi there,

This addresses some minor feedback regarding my disuse of _call_program in the
Darwin functions i added way back in January — see workers # 42235.

It also fixes a mistake that those changes made me realise i'd made in _bash —
if $words[1] needs quoted for eval, we should have already got it that way from
the command line.

dana


diff --git a/Completion/Darwin/Command/_nvram b/Completion/Darwin/Command/_nvram
index 8158eb9d2..8853b0bee 100644
--- a/Completion/Darwin/Command/_nvram
+++ b/Completion/Darwin/Command/_nvram
@@ -15,7 +15,7 @@ _arguments -s : \
 && ret=0
 
 [[ $state == variables-* ]] && {
-  tmp=( ${${(f)"$( command $service -p )"}%%[[:space:]]*} )
+  tmp=( ${${(f)"$( _call_program variables $words[1] -p )"}%%[[:space:]]*} )
 
   [[ $state == variables-rw ]] &&
   tmp=( ${^tmp}'::NVRAM variable value' )
diff --git a/Completion/Darwin/Command/_osascript b/Completion/Darwin/Command/_osascript
index 5e4a5f70c..5e6cebab5 100644
--- a/Completion/Darwin/Command/_osascript
+++ b/Completion/Darwin/Command/_osascript
@@ -18,7 +18,7 @@ case $state in
     # but adding the output of osalang makes this future-proof
     _values 'script language' \
       AppleScript JavaScript 'Generic Scripting System' \
-      ${(f)"$( command osalang 2> /dev/null )"} \
+      ${(f)"$( _call_program languages command osalang )"} \
     && ret=0
     ;;
   modifiers)
diff --git a/Completion/Darwin/Command/_say b/Completion/Darwin/Command/_say
index d687cfa11..1459c7372 100644
--- a/Completion/Darwin/Command/_say
+++ b/Completion/Darwin/Command/_say
@@ -28,9 +28,9 @@ case $state in
     # also, not every file format supports bit-rate values
     (( $+opt_args[--file-format] )) && {
       tmp=( ${(f)"$(
-        command $service \
+        _call_program bit-rates $words[1] \
           --file-format=${opt_args[--file-format]##*:} \
-          --bit-rate='?' 2> /dev/null
+          --bit-rate='\?'
       )"} )
       tmp=( ${tmp//[[:space:]]##/} )
     }
@@ -46,9 +46,9 @@ case $state in
       _message 'data format' && ret=0
     else
       tmp=( ${(f)"$(
-        command $service \
+        _call_program data-formats $words[1] \
           --file-format=${opt_args[--file-format]##*:} \
-          --data-format='?' 2> /dev/null
+          --data-format='\?'
       )"} )
       tmp=( ${tmp//:/\\:} )
       tmp=( ${^tmp/[[:space:]]##/[}\] )
@@ -56,13 +56,13 @@ case $state in
     fi
     ;;
   devices)
-    tmp=( ${(f)"$( command $service -a '?' 2> /dev/null )"} )
+    tmp=( ${(f)"$( _call_program devices $words[1] -a '\?' )"} )
     tmp=( ${tmp##[[:space:]]#[0-9]##[[:space:]]##} )
     tmp=( ${tmp//:/\\:} )
     _values 'audio device name or ID' $tmp && ret=0
     ;;
   file-formats)
-    tmp=( ${(f)"$( command $service --file-format='?' 2> /dev/null )"} )
+    tmp=( ${(f)"$( _call_program file-formats $words[1] --file-format='\?' )"} )
     tmp=( ${tmp%%[[:space:]]##\(.*} )
     tmp=( ${tmp//:/\\:} )
     tmp=( ${^tmp/[[:space:]]##/[}\] )
@@ -76,7 +76,7 @@ case $state in
     && ret=0
     ;;
   voices)
-    tmp=( ${(f)"$( command $service -v '?' 2> /dev/null )"} )
+    tmp=( ${(f)"$( _call_program voices $words[1] -v '\?' )"} )
     tmp=( ${tmp%%[[:space:]](#c2,)*} )
     _values voice $tmp && ret=0
     ;;
diff --git a/Completion/Darwin/Command/_scselect b/Completion/Darwin/Command/_scselect
index 79df2f981..ff7d2610d 100644
--- a/Completion/Darwin/Command/_scselect
+++ b/Completion/Darwin/Command/_scselect
@@ -13,7 +13,7 @@ _arguments -s -S : \
   # For some reason scselect expects location names to be encoded in Mac OS
   # Roman; in order to prevent completed arguments from breaking the tool, we'll
   # insert the UUID instead if the name would contain incompatible characters
-  tmp=( ${(f)"$( command $service 2> /dev/null )"} )
+  tmp=( ${(f)"$( _call_program locations $words[1] )"} )
   tmp=( ${tmp[2,-1]} )
   tmp=( ${tmp##[*[:space:]]##} )
   tmp=( ${tmp//:/\\:} )

diff --git a/Completion/Unix/Command/_bash b/Completion/Unix/Command/_bash
index 260ca64fb..cc219f788 100644
--- a/Completion/Unix/Command/_bash
+++ b/Completion/Unix/Command/_bash
@@ -71,12 +71,12 @@ case $state in
     fi
     ;;
   set-options)
-    tmp=( ${(f)"$( _call_program set-options ${(q-)cmd} -c '"shopt -o"' )"} )
+    tmp=( ${(f)"$( _call_program set-options $cmd -c '"shopt -o"' )"} )
     tmp=( ${tmp%%[[:space:]]*} )
     _values -w '`set` option' $tmp && ret=0
     ;;
   shopt-options)
-    tmp=( ${(f)"$( _call_program shopt-options ${(q-)cmd} -c shopt )"} )
+    tmp=( ${(f)"$( _call_program shopt-options $cmd -c shopt )"} )
     tmp=( ${tmp%%[[:space:]]*} )
     _values -w '`shopt` option' $tmp && ret=0
     ;;


                 reply	other threads:[~2018-06-13  1:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=A343459B-03F2-4DD9-8527-D55245F4A5EA@dana.is \
    --to=dana@dana.is \
    --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).