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

PATCH: _init_d: commands on the same line as case statement



Hi,
I found that some init.d scripts have commands on the same line as case 
statement. For exemple, /etc/init.d/cron on my system, has:

[...]
start)	log_daemon_msg "Starting periodic command scheduler" "crond"
[...]
stop)	log_daemon_msg "Stopping periodic command scheduler" "crond"
[...]
restart) log_daemon_msg "Restarting periodic command scheduler" "crond" 
[...]

_init_d currently does not match such constructions: It uses ':#' and 
therefore only matches case statements if there is nothing else on the line. 
If using '##' it can match case statements even if there are other things on 
the line.

I couldn't think of any drawback, so here is a patch:

arno

--- _init_d.old	2007-12-06 15:24:02.000000000 +0100
+++ _init_d	2007-12-06 15:25:24.000000000 +0100
@@ -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}([[:blank:]]#\|[[:blank:]]#${~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