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

PATCH: _init_d: handle spaces between words and pipe



Hi,

_init_d completion parse init scripts to detect "case" pattern.
It does not work when there are several cases, and spaces between words and pipe 
separator.
for example, in my /etc/init.d/apache2 file, there is

    reload | force-reload)

reload and force-reload are not part of completion suggestion

If I modify that line to

    reload|force-reload)

it works fine: reload and force-reload become part of completion suggestions.

Here is a patch that seems to fix the problem

arno.


--- _init_d.old	2007-10-04 17:33:45.000000000 +0200
+++ _init_d	2007-10-06 13:52:52.000000000 +0200
@@ -15,7 +15,7 @@
 what='(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|_stats)|add|delete|clean|list)'
 
 read -u0 -k2 magic < $script && [[ $magic = '#!' ]] &&
-    cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $script)"}:#[[:blank:]]#(\'|)${~what}(\|${~what})#(\'|)\)}}//[^-a-z_]} )
+    cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $script)"}:#[[:blank:]]#(\'|)${~what}([[:blank:]]#\|[[:blank:]]#${~what})#(\'|)\)}}//[^-a-z_]} )
 
 # This would be the pattern to use every line of the form <space>foo).
 # Some people say this might match too many lines...

Attachment: signature.asc
Description: Digital signature



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