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

Re: Truncate without padding

    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> On Oct 31, 12:27pm, DervishD wrote:
> }
> }     I would like to print a string truncated *but* without padding
> Just truncate it first with padding, and then strip the padding.
>     ${${(pl:WIDTH::::\0:)string}#*$'\0'}
>     ${${(pr:WIDTH::::\0:)string}%$'\0'*}

    I finally modified the shell function to do all string processing
first. After that, I just do "print $_rawmode -n -- $_string". So I
can do the printing in one step and the string processing in two (one
is the truncation+padding, the second is the optional padding

    I'm afraid I was misreading your suggestion: both things were done
in just one step and I thought the first expansion was the truncation
and padding and the second the padding removal. Sorry for the noise
and thanks a lot, as always, for your kind help.

    When I test the function I will probably post it here just in
case the code can be improved or anyone is interested in using it.

    Thanks again :)

    Raúl Núñez de Arenas Coronado

Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...

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