tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: shell (/bin/sh) pattern matching bugs



On Mon 25 Jun 2018 at 01:58:25 +0700, Robert Elz wrote:
>     Date:        Sun, 24 Jun 2018 19:09:58 +0200
>     From:        Rhialto <rhialto%falu.nl@localhost>
>     Message-ID:  <20180624170958.GJ8143%falu.nl@localhost>
> 
>   | Are we to assume that NetBSD's sh(1) manual page is correct?
> 
> Well, yes and no...
> 
>   | Since that clearly says that your example above should not match.
> 
> Actually, it doesn't - it just kind of slides by this case...   That is, it
> makes no mention of what happens if characters inside [ ] are
> quoted (partly because I don't much like the quoting solution,
> and never thought the ordering method was hard to get right...)

Well, I don't entirely agree. The description of patterns starts with
(sh(1) from NetBSD-7)

   Shell Patterns
     A pattern consists of normal characters, which match themselves, and
     meta-characters.  The meta-characters are ``!'', ``*'', ``?'', and ``[''.
     These characters lose their special meanings if they are quoted.  When

so I would conclude that '-' cannot lose its meaning if quoted, since it
is not a meta-character.

Added to that, that it gives some other way to include a literal '-' in
a character class, reinforces the impression that [a\-z] does not have a
quoted '-' in it. So while it doesn't explicitly say it, it leaves
little room for a different interpretation.

(All this of course apart from how things actually worked; and I
actually never realised that they didn't work like I interpret the text
here)

> The man page shouild probably be fixed to be more precise - there
> are all kinds of details it omits.

Definitely!

> kre
-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- Wayland: Those who don't understand X
\X/ rhialto/at/falu.nl      -- are condemned to reinvent it. Poorly.

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index