zsh-users
 help / color / mirror / code / Atom feed
* need help with compctl for NT
@ 1999-06-23 19:23 Amol Deshpande
  1999-06-27 13:30 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Amol Deshpande @ 1999-06-23 19:23 UTC (permalink / raw)
  To: 'zsh-users@math.gatech.edu'

hi,

I want to complete  (For zsh 3.0.x only) the command "net stop" with the
output
of the command "net start". The output looks something like this:

These Windows 2000 services are started:

   Computer Browser
   Logical Disk Manager
   Messenger
   Net Logon
   Workstation

The command completed successfully.


I came up with a completion that seems to work:

     'c[-1,stop]' -s "$(net.exe start|grep.exe -v ^T|sed.exe -ne
's/\([A-Z][a-zA
-Z].*\)/"\1"/p')" \


The only problem is that this completion only collects the output of "net
start"
on shell startup.  I would like the list to be updated every time i run "net
stop ..."

I tried using -K with a function like so:

function fooger {
    IFS=\t\n
    reply=(`net.exe start|grep.exe -v ^T|sed.exe -ne
's/\([A-Z][a-zA-Z].*\)/"\1"
/p'`); }

the problem with this approach is that it ignores the quotes and seperates
the
words anyway.

Thus, "Computer Browser" becomes
"Computer
Browser"
i.e, 2 separate array elements.


Firstly, is my assumption that the function will run every time i type 
"net stop <tab>" correct ?

If yes, then is there any way to get what I want to actually work ?

thanks,.
-amol

PS:
If all this is really confusing here's the bottom line:

How do i get a completion to be the dynamically updated output
from an external command, where the command output may
contain components with whitepace (just space usually)  ?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: need help with compctl for NT
  1999-06-23 19:23 need help with compctl for NT Amol Deshpande
@ 1999-06-27 13:30 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1999-06-27 13:30 UTC (permalink / raw)
  To: Amol Deshpande, Zsh users list

Amol Deshpande wrote:

> I came up with a completion that seems to work:
> 
>      'c[-1,stop]' -s "$(net.exe start|grep.exe -v ^T|sed.exe -ne
> 's/\([A-Z][a-zA
> -Z].*\)/"\1"/p')" \
> 
> 
> The only problem is that this completion only collects the output of "net
> start"
> on shell startup.  I would like the list to be updated every time i run "net
> stop ..."

Simply change the double quotes around the $(...) to single quotes (and
anywhere else affected by the change in quotation marks, of course).  With
the double quotes, the $(...) is getting evaluated straight away; with
single quotes it will be stored as a complete string, and expanded
separately each time.  At least, it looks that simple...

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-06-27 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-23 19:23 need help with compctl for NT Amol Deshpande
1999-06-27 13:30 ` Peter Stephenson

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).