🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Ray Nickson Mon, 04 Sep 1989 01:12
globbing bug
#538
Author: Ray Nickson
Date: Mon, 04 Sep 1989 01:12
29 lines
1814 bytes
The following bug which I reported in version 1.02 does not seem to have
gone away in 1.03.

   From:  Ray Nickson <nickson@COMP.VUW.AC.NZ>
   Date:  Tue, 08 Aug 89 16:20:36 +1200

   There is a bug in glob.c (bash version 1.02, gcc-compiled, on an hp300
   running more/bsd) which causes the following behaviour.  Switch to a
   directory containing only the files A and BC, then do echo *[^C]
   I (usually) get both files listed.  (my understanding is that BC
   shouldn't be listed).

   The problem is (not surprisingly) in the glob_match function in
   glob.c; when matching against *<something>, we try to see how much of
   our text <something> matches, and make * match enough to make this
   work.  So, we first attempt to match [^C] to BC; this fails because
   [^C] must match exactly one character.  Matching [^C] to C fails,
   because it cannot match a C.  But then, we try to match [^C] against
   the null string; the code as written will test the first character of
   the null string ('\0') against each element of the set (i.e. C); it
   won't match, so we claim that "" matches [^C].

   The easiest solution is probably to special-case the null string in
   text being matched against a set, as we do when matching against ?.

-rgn
--
Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand.
nickson@comp.vuw.ac.nz       ...!uunet!vuwcomp!nickson      + 64 4 721000x8593
Re: globbing bug
#554
Author: Spencer Garrett
Date: Thu, 07 Sep 1989 18:16
18 lines
1504 bytes
In article <8909040114.AA21411@comp.vuw.ac.nz>, nickson@comp.vuw.ac.nz (Ray Nickson) writes:
->    The problem is (not surprisingly) in the glob_match function in
->    glob.c; when matching against *<something>, we try to see how much of
->    our text <something> matches, and make * match enough to make this
->    work.  So, we first attempt to match [^C] to BC; this fails because
->    [^C] must match exactly one character.  Matching [^C] to C fails,
->    because it cannot match a C.  But then, we try to match [^C] against
->    the null string; the code as written will test the first character of
->    the null string ('\0') against each element of the set (i.e. C); it
->    won't match, so we claim that "" matches [^C].
-> 
->    The easiest solution is probably to special-case the null string in
->    text being matched against a set, as we do when matching against ?.

Argh!  The code should remember where the end of the string is, and
not try to special case some magic character.  The comparison should
always fail if you're at the end of the string, but not at the end of
the pattern.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads