This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

`expect-strings' and `with-input-from-port'


i'm trying to use ice-9/expect.scm and ran across an example posted in
1998 to this list that i'm trying to make work.  the example initially
uses `with-input-from-file', which works fine.  however, when i replace
that w/ `with-input-from-port', there is no output.

in the snippet appended below, (A) works, (B1) doesn't, but (B2) does.
am i doing something wrong here?  (this is w/ recent cvs guile.)  can
anyone get (B1) to work?

thi


-------------------------------------------
(use-modules (ice-9 popen))
(use-modules (ice-9 expect))

(set! expect-eof-proc (lambda args
                        (write-line "found eof!")
                        (write-line args)
                        (quit)))

;;; A
(with-input-from-port (open-input-pipe "cat /etc/passwd")
  (lambda ()
    (let loop ((c (read-char)))
      (or (eof-object? c)
          (begin
            (display c)
            (loop (read-char)))))))

;;; B1
(with-input-from-port (open-input-pipe "cat /etc/passwd")
;;; B2
;(with-input-from-file "/etc/passwd"
  (lambda ()
    (let loop ()
      (and (char-ready?)
           (begin
             (expect-strings
              ("^.+$"
               => (lambda all
                    (display all)
                    (newline))))
             (loop))))))

;;;;;;;;;;; snippet ends here

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]