diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2018-12-24 04:40:22 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2018-12-24 04:40:22 +0100 |
commit | bf8b7f713a5b04a191f4596fb86bbbfca0a855ce (patch) | |
tree | b647a8dc990c8c845b8a8eca7bf92fbbf17e1fb5 /Completion/Unix/Command/_init_d | |
parent | 06946d431a4426c6e5dffec1d7edb17c1dbd467c (diff) | |
parent | 9dbde9e9c7d22ee0d301e4a2fecf97906d1ddce9 (diff) | |
download | zsh-bf8b7f713a5b04a191f4596fb86bbbfca0a855ce.tar.gz zsh-bf8b7f713a5b04a191f4596fb86bbbfca0a855ce.zip |
New upstream release candidate 5.6.2-test-2
Merge branch 'upstream' at 'zsh-5.6.2-test-2' into branch debian
Diffstat (limited to 'Completion/Unix/Command/_init_d')
-rw-r--r-- | Completion/Unix/Command/_init_d | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Completion/Unix/Command/_init_d b/Completion/Unix/Command/_init_d index 03af2dc9b..cdc373297 100644 --- a/Completion/Unix/Command/_init_d +++ b/Completion/Unix/Command/_init_d @@ -80,15 +80,29 @@ else (( $+functions[_init_d_get_cmds] )) || _init_d_get_cmds() { local what magic cmds + local -a tmp - # If the file starts with `#!' we hope that this is a shell script - # and get lines looking like <space>foo|bar) with the words in $what. + [[ -x $script ]] || return 1 - what='(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|_stats)|add|delete|clean|list)' + # If the file starts with `#!' we hope that this is a shell script + # and get lines looking like <space>foo|bar) with the words in $what. Note + # that we'll fail to match if any of the alternate patterns in the case + # clause are not enumerated (e.g., `start|stop|custom)` won't match) + tmp=( + status add delete clean list + load save show check {config,}test + standalone master graceful + debug debug{_,-}{up,down} dump{,{_,-}stats} + {force-,graceful-,try-,}{start,stop,restart,reload} + {start,stop}-htcacheclean + ) + what="((['\"]|)(${(j<|>)tmp})(['\"]|))" - [[ -x $script ]] || return 1 - read -u0 -k2 magic < $script && [[ $magic = '#!' ]] && - cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $script)"}:#[[:blank:]]#(\'|)${~what}([[:blank:]]#\|[[:blank:]]#${~what})#(\'|)\)}}//[^-a-z_]} ) + read -u0 -k2 magic < $script && [[ $magic = '#!' ]] && { + cmds=( ${(f)"$(< $script)"} ) + cmds=( ${(M)cmds:#[[:blank:]]#${~what}([[:blank:]]#\|[[:blank:]]#${~what})#[[:blank:]]#\)} ) + cmds=( ${${(j:|:s:|:)cmds}//[^-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... |