Zsh Mailing List Archive
Messages sorted by:
$~var and backslash
- X-seq: zsh-workers 44429
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: $~var and backslash
- Date: Tue, 18 Jun 2019 21:34:14 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=ua/FFi4zu5S4fJ4QO4GDqMJ0nd5N98A9E3HhjUj3iZ4=; b=ddPHWKhyacSHh9Nr+rAcTJxIRlmKvnpxD1KspjJWpC/l+CwfKW0BhqdI7S1cr/0lUf 7aULQC0ozS0rlmnouuKxzmBDikBAvVtUEgW2QMZ/yrxXE011leLgg2+Ya5OJbSC9SdO6 P52XwSnsnBplFVcoOli+yCSgm19CNSf+aod2tQ5p5X6fKOL9O6XFdvvmrpk0If2cjaux MhJkovpPmdgwLc+7Xw8EFbO5satitMlM2bcCmRvOP5i8ZQrHK3ASxPCxkxXlg4Uu99V2 5NPtkoMC6UOsf0AEuiHynHh8v1HFR8uMjj9yOaQNd6DxGO5VbHVKCvx3yCjpDtbAMyVg HlyQ==
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- List-unsubscribe: <mailto:firstname.lastname@example.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
There's currently a discussion on the POSIX mailing list around
the meaning of \ in shell wildcard patterns (beside its meaning
as a quoting operator).
and the discussion that follows at
(beware it's long and still ongoing).
That's just for context, no need to read the whole discussion
to understand what I'm saying below.
zsh does seem to be doing some level of processing of backslash
when it comes to \ and pattern matching and globbing, it's not
much worse than several other shells, but I have noted a few
1. (and the main one) it's completely undocumented (and it's the
same in all the other shells that somehow treat \ as a wildcard
pattern='\*' string='*' zsh -c '[[ $string = $~pattern ]] && echo yes'
should output "yes" and not
pattern='\*' zsh -c '[[ $pattern = $~pattern ]] && echo yes'
is AFAICT not documented at all.
2. I'm not sure I can find a logic behind when \ is understood
as a quoting operator:
string='\x' pattern='\x' matches
string='\+' pattern='\+' matches
string='?' pattern='\?' matches
string='*' pattern='\*' matches
string='\' pattern='\\' matches
ok, those are wildcard operators, but:
string='\-' pattern='\-' doesn't match (but matches on string='-')
is it because - is special in <1-3> or in [a-b], but then:
string='\' pattern='[a\-a]' matches and also on
(so \ has escaped - but has not been removed?)
Same for ^ and !.
string='|' pattern='\|' matches but not with shglob. Yet
string='~' pattern='\~' matches both with and without shglob.
It doesn't make much sense to me.
One can always use [|] pr [~] instead of \ (which is also the
most portable in other shells), so it's not very critical.
Messages sorted by: