Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Truncate without padding
- X-seq: zsh-users 9599
- From: DervishD <zsh@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Truncate without padding
- Date: Tue, 1 Nov 2005 00:56:40 +0100
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <1051031153512.ZM17476@xxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: DervishD
- References: <20051031112743.GA1048@DervishD> <1051031153512.ZM17476@xxxxxxxxxxxxxxxxxxxxxxx>
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
removal).
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