Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*---------------------------------------------------------------------------
  2.  
  3.    zipgrep.cmd  (ye olde REXX procedure for OS/2)
  4.  
  5.    Script to search members of a zipfile for a string or regular expression
  6.    and print the names of any such members (and, optionally, the matching
  7.    text).  The search is case-insensitive by default.
  8.  
  9.    History:
  10.      original Bourne shell version by Jean-loup Gailly
  11.      modified by Greg Roelofs for Ultrix (no egrep -i) and zipinfo -1
  12.      OS/2 REXX script by Greg Roelofs
  13.  
  14.    Last modified:  19 Jul 93
  15.  
  16.   ---------------------------------------------------------------------------*/
  17.  
  18. PARSE ARG string zipfile members
  19.  
  20. if (string == '') then do
  21.     say 'usage:  zipgrep search_string zipfile [members...]'
  22.     say '   Displays the names of zipfile members containing a given string,'
  23.     say '   in addition to the matching text.  This procedure requires unzip'
  24.     say '   and egrep in the current path, and it is quite slow....'
  25.     exit 1
  26. end
  27.  
  28. /* doesn't seem to work...
  29. newq = RXQUEUE("Create",zipgrep_pipe)
  30. oldq = RXQUEUE("Set",newq)
  31.  */
  32.  
  33. /* flush the queue before starting */
  34. do QUEUED()
  35.     PULL junk
  36. end
  37.  
  38. /* GRR:  can also add "2>&1" before pipe in following external command */
  39. '@unzip -Z1' zipfile members '| rxqueue'
  40.  
  41. do while QUEUED() > 0
  42.     PARSE PULL file
  43.     '@unzip -p' zipfile file '| egrep -is' string
  44.     if rc == 0 then do
  45.         SAY file':'
  46.         /* can comment out following line if just want filenames */
  47.         '@unzip -p' zipfile file '| egrep -i' string
  48.     end
  49. end
  50.  
  51. /*
  52. call RXQUEUE "Delete",newq
  53. call RXQUEUE "Set",oldq
  54.  */
  55.  
  56. exit 0
  57.