home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.bsd
- Path: sparky!uunet!spool.mu.edu!umn.edu!umeecs!quip.eecs.umich.edu!dmuntz
- From: dmuntz@quip.eecs.umich.edu (Dan Muntz)
- Subject: [386BSD] csh globbing bug
- Message-ID: <1993Jan5.051039.29362@zip.eecs.umich.edu>
- Sender: news@zip.eecs.umich.edu (Mr. News)
- Organization: University of Michigan EECS Dept., Ann Arbor, MI
- Date: Tue, 5 Jan 1993 05:10:39 GMT
- Lines: 74
-
- I don't know if this one has been mentioned or fixed.
- Any wildcard which fails to match anything causes a "No match" for the
- entire argument list. The included patch takes care to mimic the
- standard globbing of csh (if it has been changed for POSIX or somesuch
- someone please let me know :)
-
- To see the bug:
-
- % ls
- foo.a bar.b
- % ls *.b *.c
- ls: No match.
-
- -Dan
- dmuntz@eecs.umich.edu
-
- And the patch (to /usr/src/bin/csh/glob.c):
-
- *** glob.c.ORIG Sun Jan 3 19:45:16 1993
- --- glob.c Sun Jan 3 23:46:47 1993
- ***************
- *** 354,360 ****
- libglob(vl)
- Char **vl;
- {
- ! int gflgs = GLOB_QUOTE | GLOB_NOCHECK;
- glob_t globv;
- char *ptr;
-
- --- 354,360 ----
- libglob(vl)
- Char **vl;
- {
- ! int gflgs = GLOB_QUOTE | GLOB_NOCHECK, badmagic = 0, goodmagic = 0;
- glob_t globv;
- char *ptr;
-
- ***************
- *** 377,388 ****
- }
- if (!nonomatch && (globv.gl_matchc == 0) &&
- (globv.gl_flags & GLOB_MAGCHAR)) {
- ! globfree(&globv);
- ! return (NULL);
- ! }
- gflgs |= GLOB_APPEND;
- }
- while (*++vl);
- vl = blk2short(globv.gl_pathv);
- globfree(&globv);
- return (vl);
- --- 377,397 ----
- }
- if (!nonomatch && (globv.gl_matchc == 0) &&
- (globv.gl_flags & GLOB_MAGCHAR)) {
- ! badmagic = 1;
- ! globv.gl_pathc--;
- ! free(globv.gl_pathv[globv.gl_pathc]);
- ! globv.gl_pathv[globv.gl_pathc] = (char *)0;
- ! } else
- ! if (!nonomatch && (globv.gl_matchc > 0) &&
- ! (globv.gl_flags & GLOB_MAGCHAR))
- ! goodmagic = 1;
- gflgs |= GLOB_APPEND;
- }
- while (*++vl);
- + if (badmagic && !goodmagic) {
- + globfree(&globv);
- + return (NULL);
- + }
- vl = blk2short(globv.gl_pathv);
- globfree(&globv);
- return (vl);
-
-