zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _cdrecord
@ 2006-06-02 19:08 Tobias Gruetzmacher
  0 siblings, 0 replies; only message in thread
From: Tobias Gruetzmacher @ 2006-06-02 19:08 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

Since "cdrecord -scanbus" can be expensive on some systems, this patch
caches the response of the call to "cdrecord -scanbus". I don't know if
this is the best solution since the device configuration may change very
fast (e.g. USB burners). Nevertheless, here's the patch:

--- Completion/Unix/Command/_cdrecord	8 Jun 2005 05:33:47 -0000	1.5
+++ Completion/Unix/Command/_cdrecord	2 Jun 2006 18:59:12 -0000
@@ -1,7 +1,7 @@
 #compdef cdrecord
 
 local curcontext="$curcontext" state line expl ret=1
-local devices btypes
+local btypes
 
 _arguments -C \
   '-version[print version information]' \
@@ -89,9 +89,12 @@
   
   case $state in
     device)
-      devices=( ${(f)"$(_call_program device cdrecord -scanbus 2>/dev/null \
+      if (( ! $+_cdrecord_device )); then
+        typeset -gH _cdrecord_devices
+        _cdrecord_devices=( ${(f)"$(_call_program device cdrecord -scanbus 2>/dev/null \
           |grep '^	'|cut -c2-6,23-|sed 's/ /:/')"} )
-      _describe -t devices device devices && return
+      fi
+      _describe -t devices device _cdrecord_devices && return
     ;;
     blank)
       btypes=(

Greetings, Tobi

-- 
GPG-Key 0xE2BEA341 - signed/encrypted mail preferred
My, oh so small, homepage: http://portfolio16.de/
http://www.fli4l.de/ - ISDN- & DSL-Router on one disk!
Registered FLI4L-User #00000003

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-02 19:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-02 19:08 PATCH: _cdrecord Tobias Gruetzmacher

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