* PATCH: _init_d: commands on the same line as case statement
@ 2007-12-06 14:34 arno
0 siblings, 0 replies; only message in thread
From: arno @ 2007-12-06 14:34 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]
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 #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:[~2007-12-06 14:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-06 14:34 PATCH: _init_d: commands on the same line as case statement arno
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).