Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: _cdrecord



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: signature.asc
Description: Digital signature



Messages sorted by: Reverse Date, Date, Thread, Author