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

non-greedy matching?



Sorry, I seem to be coming out with a lot of dumb questions recently.

In my quest to improve my zsh startup time, I noticed to my horror
that when I initially coded prompt_adam2_setup, I made it invoke perl
no less than three times.  Eliminating one of them is fairly easy;
however the other two invocations are:

  ..... | perl -pe 's/%{.*?%}//g'

They are done in order to strip control characters from a prompt so
that its display width can be determined.  At first I thought that it
would surely be easy to avoid this, but I still haven't come up with a
quick replacement, since neither zsh nor sed seem to be able to do
non-greedy matching.

Any ideas?  The only alternatives I've come up with are:

  foo=$(print -P "$prompt_string")
  bar="${foo//^[[[0-9;]##m/}"

the string and then strip out ANSI escape sequences, or maybe to use
the (^(...)) extended glob somehow, but I haven't managed to get the
latter working.

It would be nice if zsh could do non-greedy though.



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