[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unix tools...

>Date: Tue, 21 Apr 92 14:42:19 PDT
>From: mmeehan@eesof.com (Mike Meehan)
>To: info-mcl@cambridge.apple.com
>Subject: unix tools...
>Anyone know of a "UNIX like" toolkit (preferably in MCL) to do such things
>as sed, cp -r, etc...?
>ttfn, MM

I'm not sure why you want "unix-like" tools on a Mac when there's much 
nicer ones that are "Mac-like". The Finder copies just like "cp -r",
and popular DA's like Gofer or OnLocation are a heck of a lot superior 
to grep. All of these of course can be called from MCL (or Hypercard, 
or QuicKeys, etc...) using Apple Events.

For sed-like string manipulation, MCL gives you WITH-OPEN-FILE and 
all the string operations you could ask for. If you want "cp -r" in
MCL, Bill posted this just a week or two ago...


(defun copy-directory (from-dir to-dir &key
                                (if-exists :error)
  (let* ((mac-from-dir (mac-namestring from-dir))
         (mac-to-dir (mac-namestring to-dir))
         (mac-from-dir-length (length mac-from-dir))
         (did-one nil))
    (flet ((require-directory (string original)
             (unless (eql #\: (char string (1- (length string))))
               (error "~s is not a directory" original))))
      (require-directory mac-from-dir from-dir)
      (require-directory mac-to-dir to-dir))
    (dolist (from-file (directory (concatenate 'string mac-from-dir "**:*")))
      (let* ((namestring (mac-namestring from-file))
             (to-file (concatenate 'string
                                   (subseq namestring
                                           (length namestring)))))
        (when verbose
          (format t "~&Copying ~s to ~s..." from-file to-file)
          (setq did-one t))
        (copy-file from-file to-file :if-exists if-exists)))
    (when did-one (terpri))))