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

Re: please consider using PCRE_DOLLAR_ENDONLY (and PCRE_DOTALL) for rematchpcre



2018-01-23 06:57:35 +0000, Stephane Chazelas:
[...]
> It's more about single-line where the line delimiter happens to
> be included (and you want the $ to match on the end of that line
> as opposed to the end of the string).
[...]

I've been trying to imagine a use case that could be broken by
the change (of adding PCRE_DOLLAR_ENDONLY).

One case could be with $mapfile[file] (which does expand to the
full content of the file) for text files with a single line, like

set -o rematchpcre
zmodload zsh/mapfile
[[ $mapfile[/etc/debian_version] =~ '/sid$' ]]

Which would have to be changed to:

[[ $mapfile[/etc/debian_version] =~ '/sid\n?$' ]]

or

[[ $mapfile[/etc/debian_version] =~ '/(?m)sid$' ]]

though personally, I'd rather do:

[[ $(</etc/debian_version) = */sid ]]

Or 

grep -q '/sid$' /etc/debian_version

Can anyone think of less far-fetched ones?

-- 
Stephane



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