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

Re: help using ~~



Gregory L. Snead wrote
>   I'm trying out pattern extraction, but I'm not getting what I
> want.  What am I doing something wrong?  Here is what I want to
> do:
> 
>  Given the file name 
>     b0302001.lisp
>   I want to convert it to
>     d0302001.lisp
>     p0302001.lisp
> 
>   Here's what I tried
>     ; echo <={~~ (b0302001.lisp) b???????.lisp}
>     0 3 0 2 0 0 1
>     ; echo <= {~~ (b0302001.lisp) b*.lisp}
>     
>     ;
> 
>   The first try extracted what I wanted but in the wrong form. I
> expected the results to be
>     0302001
>   not
>     0 3 0 2 0 0 1

Each ? is a separate wildcard.  The manual says:

  Each subject is checked in order against each pattern;  if it matches
  the pattern, the parts of the subject which matched each *, ?, or []
  character range are extracted, [...]

So it's doing what I intended.  Coalescing patterns seemed like the
wrong thing to do.

>   The second try didn't extract anything.  Why not?

It's a bug.  Hunting this down proved next to impossible, because I
rebuilt a version for the machine you said you use (SunOS 4.1) and it
worked just fine, and I couldn't reproduce it on any other machine.
But, and this is what drove me crazy, I was able to reproduce the bug
in the copy of es in ~/bin/sunos-4 on my machine at work.

Looking back at the RCS history, it's a bug from the first version of
pattern extraction I had written, which was the last thing I fixed
before the release.  I didn't notice it was still there because I
rarely use suns.

So how did Greg trip over it?  Well, it just happens that we work at
the same company (though 8000 miles apart;  we've never met and he was
using es before I came here) and I had sent him private mail saying
``You don't have to rebuild; just snarf the copy from my directory.''

[Sound of heading smacking against wall.]

Ok, so it was bad advice.  Ftp the public release of the shell and
build it from scratch;  that version works correctly.

Paul