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

Re: PATCH: Re: completion function for apachectl



On Feb 26,  6:17pm, Andrej Borsenkow wrote:
}
} > +_sub_commands start stop
} 
} Well, Linux strikes again. You can be sure only in the above; restart and
} status are not universally supported.

One could probably pull a stunt like this:

_sub_commands $(sed -ne '/case/,/esac/{;s/^ *\([a-z|)]*\).*/\1/g;s/[|)]/ /gp;}' $words[1])

Runs a slight risk of finding case-labels that aren't actually part of the
argument parsing -- on a RedHat 6.2 machine it finds y, n, and c in one of
the scripts -- but for the most part it's pretty accurate.

Tuning the regex and adapting to older seds left as an exercise.


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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