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

Re: egrep --color=always 'zsh\.'





On 2024-04-02 13:14, Lawrence Velázquez wrote:
The issue is probably that you are using the same pattern for both
"apt-file search" and egrep, but they don't interpret it in the
same way.  By default, "apt-file search" does a literal substring
match, so "\." will match backslash-period.
Right, I know that, my code sample was too lazy.  The only issue is with the egrep.
The function as presented cannot actually work with regex arguments,
so just switch to "grep -F" and avoid the escaping issues altogether.
If there's no way for the shell to handle it, then that's just what I'll do.  Still .... I'm almost sure I've had to deal with this before.  IIRC every situation I've come up against has been handled by the right combination of quotes and backslashes ... I think.

Please refrain from referring to zsh as "she". The shell is neither
a woman nor a ship.
Sure.  But things besides ships are feminized.  Never mind.  As you wish.
No, egrep does not need the quotes.
% apt-file search zsh-theme | egrep --color=always zsh.
...
zsh-theme-powerlevel9k: /usr/share/powerlevel9k/powerlevel9k.zsh-theme

% apt-file search zsh-theme | egrep --color=always zsh\.
...
zsh-theme-powerlevel9k: /usr/share/powerlevel9k/powerlevel9k.zsh-theme

% apt-file search zsh-theme | egrep --color=always 'zsh.'
...
zsh-theme-powerlevel9k: /usr/share/powerlevel9k/powerlevel9k.zsh-theme

% apt-file search zsh-theme | egrep --color=always 'zsh\.'
[ no match ]

... the dot is matching the dash -- or anything else -- unless I use:  'zsh\.'

% apt-file search zsh. | egrep --color=always 'zsh\.'
...
zsh-doc: /usr/share/info/zsh.info.gz

... the dot is matched.  Mind, it was easy to be fooled because : egrep zsh.
... the dot matches any character *including* a literal dot. 





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