#!/bin/sh
: ; exec klone $0 "$@"
; The above line finds the klone executable in the $PATH
;;Skeleton of a typical klone script
;;(stack-dump-on-error t)
;;(kdb t)

(setq args (getopts "USAGE: file-is-size size file
returns true is file is of size size (in bytes), false otherwise.
Useful in shell scripts: 
    while file-is-size -n 54673 foo;do getftp -r foo;done"
    ("-v" () verbose "verbose operation")
    ("-n" () negate "negation: tests if files is NOT of size")
))

(defun main (&aux
  )
  (setq size (Int (get args 0 '(progn (sh file-is-size -?) (exit 1)))))
  (setq file (get args 1 '(progn (sh file-is-size -?) (exit 1))))
  (setq res (and (setq stat (file-stats file))
      (= size (get stat 'size))
  ))
  (if negate (setq res (not res)))
  (if res
    (exit 0)
    (exit 1)
))

(main)

;;; EMACS MODES
;;; Local Variables: ***
;;; mode:lisp ***
;;; End: ***

