home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / bsd / 10911 < prev    next >
Encoding:
Text File  |  1993-01-05  |  2.1 KB  |  85 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!spool.mu.edu!umn.edu!umeecs!quip.eecs.umich.edu!dmuntz
  3. From: dmuntz@quip.eecs.umich.edu (Dan Muntz)
  4. Subject: [386BSD] csh globbing bug
  5. Message-ID: <1993Jan5.051039.29362@zip.eecs.umich.edu>
  6. Sender: news@zip.eecs.umich.edu (Mr. News)
  7. Organization: University of Michigan EECS Dept., Ann Arbor, MI
  8. Date: Tue, 5 Jan 1993 05:10:39 GMT
  9. Lines: 74
  10.  
  11. I don't know if this one has been mentioned or fixed.
  12. Any wildcard which fails to match anything causes a "No match" for the
  13. entire argument list.  The included patch takes care to mimic the 
  14. standard globbing of csh (if it has been changed for POSIX or somesuch
  15. someone please let me know :)
  16.  
  17. To see the bug:
  18.  
  19. % ls
  20. foo.a   bar.b  
  21. % ls *.b *.c
  22. ls: No match.
  23.  
  24.   -Dan
  25.    dmuntz@eecs.umich.edu
  26.  
  27. And the patch (to /usr/src/bin/csh/glob.c):
  28.  
  29. *** glob.c.ORIG    Sun Jan  3 19:45:16 1993
  30. --- glob.c    Sun Jan  3 23:46:47 1993
  31. ***************
  32. *** 354,360 ****
  33.   libglob(vl)
  34.       Char  **vl;
  35.   {
  36. !     int     gflgs = GLOB_QUOTE | GLOB_NOCHECK;
  37.       glob_t  globv;
  38.       char   *ptr;
  39.   
  40. --- 354,360 ----
  41.   libglob(vl)
  42.       Char  **vl;
  43.   {
  44. !     int     gflgs = GLOB_QUOTE | GLOB_NOCHECK, badmagic = 0, goodmagic = 0;
  45.       glob_t  globv;
  46.       char   *ptr;
  47.   
  48. ***************
  49. *** 377,388 ****
  50.       }
  51.       if (!nonomatch && (globv.gl_matchc == 0) &&
  52.           (globv.gl_flags & GLOB_MAGCHAR)) {
  53. !         globfree(&globv);
  54. !         return (NULL);
  55. !     }
  56.       gflgs |= GLOB_APPEND;
  57.       }
  58.       while (*++vl);
  59.       vl = blk2short(globv.gl_pathv);
  60.       globfree(&globv);
  61.       return (vl);
  62. --- 377,397 ----
  63.       }
  64.       if (!nonomatch && (globv.gl_matchc == 0) &&
  65.           (globv.gl_flags & GLOB_MAGCHAR)) {
  66. !         badmagic = 1;
  67. !         globv.gl_pathc--;
  68. !         free(globv.gl_pathv[globv.gl_pathc]);
  69. !         globv.gl_pathv[globv.gl_pathc] = (char *)0;
  70. !     } else
  71. !         if (!nonomatch && (globv.gl_matchc > 0) && 
  72. !         (globv.gl_flags & GLOB_MAGCHAR))
  73. !         goodmagic = 1;
  74.       gflgs |= GLOB_APPEND;
  75.       }
  76.       while (*++vl);
  77. +     if (badmagic && !goodmagic) {
  78. +     globfree(&globv);
  79. +     return (NULL);
  80. +     }
  81.       vl = blk2short(globv.gl_pathv);
  82.       globfree(&globv);
  83.       return (vl);
  84.  
  85.