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

Re: PATCH: Re: completion function for apachectl



On Mon, 26 Feb 2001, Bart Schaefer wrote:

> 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.
>
>

I prefer explicit search for (start|stop|restart|status|reload). It is
what is used on Linux (just checked) and we can always add more labels
if needed. Searching for every label will find too much.

One small problem is binary programs (at least our system sometimes did
that). So, '2> /dev/null' is needed and at least (start|stop) should be
fallback.

-andrej



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