scsh-users
[Top] [All Lists]

Braino or bad form?

To: scsh-bugs@martigny.ai.mit.edu
Subject: Braino or bad form?
From: xjam@fir.CS.Berkeley.EDU
Date: Fri, 19 May 1995 12:35:10 -0700
Reply-to: xjam@cork.cs.berkeley.edu
When scsh went from 0.2 to 0.3, doing a load from a batch script bombed
out. For example, the following script:

----------------------------------------------------------------------
#!/home/fir/local/bin/scsh -s
!#
(load "/home/barad-dur/e/mhgs/xjam/junk/fib.scm")
(display (fib 20))
(newline)
----------------------------------------------------------------------

Would result in the following:
----------------------------------------------------------------------
/home/barad-dur/e/mhgs/xjam/junk/fib.scm ..

Error: undefined variable
       fib
       (package user)
----------------------------------------------------------------------

Now at the time I just wrote it off as a bug and reported. Olin chalked it
up to the scheme48 module system. I got involved in other things and never
pursued it.

Now that I've come back to a little scsh hacking it really bugged me that
this error should be blamed on scheme48 since it didn't change between
scsh 0.2 and 0.3. 

So poking around in scsh/top.scm I notice that make-scsh-starter has
changed and in particular there's now a special branch for batch files. To
get to the point I think the new version is simply using the wrong
environment/package/whatever (side note: Are mere mortals supposed to
understand the module system?). I just made a mindless hack to
make-scsh-starter (code follows below). This may or may not be the right
thing but my script now works. Now at least I can chunk up big scripts
into small files and get some modularity.

----------------------------------------------------------------------
(define (make-scsh-starter)
  (let ((env (environment-for-commands))
        (context (user-context)))
    (lambda (args)
      (set! %internal-full-command-line args)
      (init-scsh #f)
      (receive (script args) (parse-scsh-args args)
        (set! command-line-arguments (append args '()))
        (cond (script           ;Batch
               (set! %internal-command-line-arguments
                     (cons script args))
               ;; Let's try using interaction-environment just for kicks
               (load-quietly1 script (interaction-environment)) ;; line added 
by xjam
               ;; notice how this load uses the same old environment as the
               ;; else branch
               ;; (load-quietly1 script env) 
               0)                       ; exit code

              (else             ; Interactive
               (with-interaction-environment env
                 (lambda ()
                   (set-batch-mode?! #t)
                   (set! %internal-command-line-arguments
                         (cons "scsh" args))
                   (start-command-processor ""
                                            context
                                            (lambda ()
                                              (display "Scsh ")
                                              (display scsh-version-string)
                                              (newline)
                                              ))))))))))
----------------------------------------------------------------------
                                                        --BriD


<Prev in Thread] Current Thread [Next in Thread>
  • Braino or bad form?, xjam <=