#!/bin/sh
exec lush "$0" "$@"
!#

(libload "libc/shell")
(if (or (member "-h" argv) (member "--help" argv))
    (progn
      (printf "%s [-h] pattern dir1 [dir2] ....[dirN]\n" (car argv))
      (printf " prints all occurences of string <pattern> in\n")
      (printf " all .lsh files in directories dir1....dirN\n")
      (printf " example: %s named lsh packages local\n" (car argv)))
  (progn
    (setq pat (cadr argv))
    (each ((d (cddr argv)))
      (let ((flist (sh-find d "*.lsh")))
	(each ((f flist))
	  (each ((m (sh (concat "grep -n " pat " " f))))
	    (printf "%s: %s\n" f m)))))))

