Re: dot gob+extglob bug

2014-07-14 Thread Ian Kelling

The pathexp-globignore-delim.patch seems to work as advertised.

 If *a matches scratch/a, for
 example, that's a bug in the matching code I will have to identify and fix.

Yes, this is the case. Based on your reply, the examples I showed are
definitely a bug.

Thank you so much.





Re: dot gob+extglob bug

2014-06-20 Thread Chet Ramey
On 6/19/14, 6:47 PM, Ian Kelling wrote:

 The doc says When matching a pathname, the slash character
 must always be matched explicitly.  Shortly thereafter, in the next
 paragraph of the same section, GLOBIGNORE is described, which does not
 treat / as special, but this is not mentioned, and is very unexpected to
 me. Closer inspection, I see same language filenames matching a
 pattern is used in both paragraphs, so I think some clarification is
 needed.

The GLOBIGNORE matching code treats the patterns and strings to be matched
as pathnames, and treats `/' specially (that is, it specifies FNM_PATHNAME
to bash's internal version of fnmatch).  If *a matches scratch/a, for
example, that's a bug in the matching code I will have to identify and fix.
None of `*', `?', or bracket expressions should match a slash.

 And then, another bug or doc clarification. The various [:class:] forms
 don't seem to work at all in GLOBIGNORE.

Yeah, this is a different problem caused by an oversight.  The colon in the
bracket expression is being treated as a pattern delimiter.  I've appended
a patch that fixes this problem.

Chet


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.3-patched/pathexp.c	2014-01-31 09:34:33.0 -0500
--- pathexp.c	2014-06-20 15:33:09.0 -0400
***
*** 539,543 
  return 0;
  
!   n = skip_to_delim (s, i, :, SD_NOJMP|SD_EXTGLOB);
t = substring (s, i, n);
  
--- 539,543 
  return 0;
  
!   n = skip_to_delim (s, i, :, SD_NOJMP|SD_EXTGLOB|SD_GLOB);
t = substring (s, i, n);
  


Re: dot gob+extglob bug

2014-06-19 Thread Ian Kelling
Chet Ramey chet.ra...@case.edu writes:
 On 6/9/14, 3:42 PM, Ian Kelling wrote:
 Yes, it's an interesting question: what exactly does pattern negation
 include?  You can match all filenames beginning with a `.' by using `.'
 as the first character of the pattern, so should a negated pattern
 beginning with a `.' match all filenames beginning with a `.' that don't
 match that particular pattern?  The bash-4.3 implementation says yes.
 (FWIW, ksh93 disagrees.)

Yes, now I understand. I agree with this bash 4.3 behavior.

As you pointed out, some of my comments about past bash were
wrong. Thank you. Now I think I have I have explored properly the latest
version and found some problems I did not fully see before:

The doc says When matching a pathname, the slash character
must always be matched explicitly.  Shortly thereafter, in the next
paragraph of the same section, GLOBIGNORE is described, which does not
treat / as special, but this is not mentioned, and is very unexpected to
me. Closer inspection, I see same language filenames matching a
pattern is used in both paragraphs, so I think some clarification is
needed.

# example: / matters to GLOBIGNORE 
~/opt/bash (master) $ ./bash --norc
bash-4.3$ cd $(mktemp -d)
bash-4.3$ touch a
bash-4.3$ GLOBIGNORE=a
bash-4.3$ echo *
*
bash-4.3$ echo ./*
./a
# another example of the same phenomenon
bash-4.3$ GLOBIGNORE='*a'
bash-4.3$ echo ./*
./*

And then, this definitely seems like a bug: * matches / in
GLOGIGNORE, and so does [/], but ? does not match /

# example: ? does not match /
bash-4.3$ GLOBIGNORE=.?a
bash-4.3$ echo ./*
./a
# example: ? does match x
bash-4.3$ touch .xa
bash-4.3$ echo .x*
.x*
# example: [/] matches /
bash-4.3$ GLOBIGNORE=.[/]a
bash-4.3$ echo ./*
./.xa

And then, another bug or doc clarification. The various [:class:] forms
don't seem to work at all in GLOBIGNORE.


Side note, I've added to my bashrc:
GLOBIGNORE=*/.:*/..