scsh-users
[Top] [All Lists]

Re: help understand a script

To: scsh@zurich.csail.mit.edu
Subject: Re: help understand a script
From: ZHAO Wei <zhaoway@public1.ptt.js.cn>
Date: Sun, 02 Nov 2003 00:55:41 +0800
Thanks a great lot!

Previously I thought this was probably caused by a combination of the awk macro and run macro! Thanks for pointing out the correct direction!

Thanks,
zw

stktrc wrote:
ZHAO Wei <zhaoway@public1.ptt.js.cn> writes:

The following script. I can't understand the output which is only two
"yes" without "haha". I think there should be a "haha" in the
output. Please help me clarify! Thank you!

#! /usr/bin/scsh \
-o threads -e main -s
!#

(define (main ignore)
  (let* ((headache (lambda ()
                     (spawn (lambda ()
                              (run (begin (display "haha") (newline)))))))
         (watcher (lambda ()
                   (awk (read-line) (line) ()
                        (#t (display line) (newline)
                            (headache)
                            (display line) (newline))))))
    (run (| (echo "yes") (begin (watcher))))
    (sleep (* 3600 1000))))

I believe there is a SCSH bug, but I'm not sure.  A work around is to
add a (sleep 1) immediately after the spawn.

Change this:

 (spawn (lambda ()
          (run (begin (display "haha") (newline)))))))

to:

 (spawn (lambda ()
          (run (begin (display "haha") (newline)))))
 (sleep 1)))

Does this work around fix it for you?

--
zhaoway@public1.ptt.js.cn
http://c2.com/cgi/wiki?ZhaoWay
http://advogato.org/person/zhaoway/
linux.ext2fs.tcp.ip.netfilter.gnu.debian.dpkg.rpm.bash.lex
yacc.gcc.lisp.scheme.ocaml.latex.html.css.php.apache.mysql


<Prev in Thread] Current Thread [Next in Thread>