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

Re: PATCH Re: infinite loop in prompt expansion

On Oct 1, 11:35am, Laurent Wacrenier wrote:
} Subject: Re: PATCH Re: infinite loop in prompt expansion
} Le Lun 30 sep 18:32:30 2002, Bart Schaefer écrit:
} > It shouldn't infinte loop, but I'd like to point out that it also is
} > not intended to do anything useful.
} This may have a sense within PS1 to set a xterm title or a terminal
} status line.

I guessed that was what you wanted, but it doesn't work.

Consider what happens when you put the %8<..< *outside* the %{ %} like so:

% print -P '%8<..<%{%/%}987654321'

The manual says:
  "The string within the braces should not change the cursor position."

Therefore zsh counts zero characters for everything from the %{ through
the matching %}, and applies the truncation to whatever comes after it.

Even when the %8<..< is put inside the braces, zsh is still counting zero
characters for everything through the ending %}.  That's what confuses
the truncation code into going into an infinite loop.
} > Hence the fix (which is probably not going to make you happy) is this:
} Well... that's not what's wroten in the manual.

The manual says:

     "The part of the prompt string to be truncated runs to the end of
     the string, or to the end of the next enclosing group of the `%('
     construct, or to the next truncation encountered at the same
     grouping level (i.e. truncations inside a `%(' are separate), which
     ever comes first."

Note that it *doesn't* say that it ends at the closing %} that matches a
preceding %{.

I think I've got a patch (by introducing Yet Another Global) that will
allow that to work, but I'd like to hear more zsh-workers' opinions first.

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