Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Match to the end of string when using (S) flag
- X-seq: zsh-users 22062
- From: Sebastian Gniazdowski <psprint@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Match to the end of string when using (S) flag
- Date: Tue, 01 Nov 2016 09:27:53 -0700
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=9e7dB6NnhOCOKlt aXGZwDEpJD4I=; b=wWZYDMBu7Pnr7A8xq/r6wij6Aeuc4/YaTLUSmStAa9fz17p 5nbvuQ6iY6fGi6O5S2WgxxNlSqvcKtsYsgr+e2Y5sMAStzyvZS2MfxtYXGFLJxhU 9m3tVovIcq5Lg/1BfywDP90wx5E3SM0vfsPWOKejyLaMgue31hNjCrmPZEsQ=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=9e7dB6NnhOCOKltaXGZwDEpJD4I=; b=DuxVONc1BswGjR9PFSY2 Mectp8bGtAIATgJtY65yGyhNdKEsyHoxiRCapWZX8IL+gyRJxISqhSsd8YZhNkOI 7GpkylbinSQonxIpdHpa31VtXiVnKnfC54yNMu1qfBmR2KWEMkq/69J6jv41zEfz G4HF+QoyQne5KikPMgJnCHI=
- In-reply-to: <1478010333.3056500.773811025.1AAA4FEC@webmail.messagingengine.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <1478010333.3056500.773811025.1AAA4FEC@webmail.messagingengine.com>
One solution can be:
local nul=$'\0'
region_highlight+=( "${(0)${(S)text//*(#bi)(${~colsearch_pattern})/$((
offset + mbegin[1] - 1 )) $(( offset + mend[1] ))
${__hsmw_hl_color}${nul}}%$nul*}" )
however user probably can enter or somehow have in history a null byte?
That said, the solution is rather acceptable. Generates clean
region_highlight entries and in emergency case of a null byte in $text
after last match – relies on Zshell's robust region_highlight
implementation converting improper entries to "-1 -1 none". Provided
there is no other way, this is fine. But maybe there is other way?
--
Sebastian Gniazdowski
psprint@xxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author