#! /usr/local/bin/scm \ %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
- !#
;;;;"cvsfiles" List CVS-controlled files in directory
;;; Copyright 1998-2002 Aubrey Jaffer
;
;Permission to copy this software, to modify it, to redistribute it,
;to distribute modified versions, and to use it for any purpose is
;granted, subject to the following restrictions and understandings.
;
;1.  Any copy made of this software must include this copyright notice
;in full.
;
;2.  I have made no warranty or representation that the operation of
;this software will be error-free, and I am under no obligation to
;provide any services, by way of maintenance, update, or otherwise.
;
;3.  In conjunction with products arising from the use of this
;material, there shall be no use of my name in any advertising,
;promotional, or sales literature without prior written consent in
;each case.

(define (cvsfiles.script args)
  (define status #t)
  (for-each (lambda (file)
	      (cond ((not (positive? (string-length file)))
		     (set! status #f))
		    ((eqv? #\- (string-ref file 0))
		     (set! status #f))
		    ((eqv? #\/
			   (string-ref file (+ -1 (string-length file)))))
		    (else (set! status #f))))
	    args)
  (cond ((not (<= 1 (length args)))
	 (cvsfiles.usage))
	((not status)
	 (cvsfiles.usage))
	(else
	 (apply cvsfiles args) #t)))

(define (cvsfiles.usage)
  (display "\
\
Usage: cvsfiles dir1/ [...]
\
  Outputs a list of CVS controlled files in DIR1/ and its (their)
  subdirectories.

http://swissnet.ai.mit.edu/~jaffer/Docupage/index.html
"
	   (current-error-port))
  #f)

(require 'line-i/o)
(require 'cvs)

(define (cvsfiles . args)
  (for-each (lambda (file)
	      (for-each write-line (cvs-files file)))
	    args))

;;; Local Variables:
;;; mode:scheme
;;; End:
(if *script* (exit (cvsfiles.script (list-tail *argv* *optind*))))
