Hello,
I'm trying to find a way of knowing if some code is being run interactively or in batch mode. Is there a reliable way for this?
Thank you
Afficher les réponses par date
I’m not sure what you mean. Can you give an example of what you want to do? Do you want to distinguish between (load "foo.scm") and
gsi foo.scm
There is no general way to distinguish them. Howwever, if you use start the Scheme file with a shebang line, then you could do something like this:
% cat load-test.scm #! /usr/bin/env gsi
(define (interactive-load?) (equal? (##command-line) ##processed-command-line))
(if (interactive-load?) (pp 'interactive-load) (pp 'batch-load)) % gsi load-test.scm batch-load % gsi Gambit v4.7.4
(load "load-test.scm")
interactive-load "/Users/feeley/load-test.scm"
Marc
On Mar 15, 2015, at 9:03 AM, Álvaro Castro-Castilla alvaro.castro.castilla@gmail.com wrote:
Hello,
I'm trying to find a way of knowing if some code is being run interactively or in batch mode. Is there a reliable way for this?