~williewillus/public-inbox

r16: Display custom-write? results in sandbox context v1 SUPERSEDED

eutro
eutro: 1
 Display custom-write? results in sandbox context

 2 files changed, 13 insertions(+), 7 deletions(-)
#471471 linux_buildtest.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~williewillus/public-inbox/patches/21551/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH r16] Display custom-write? results in sandbox context Export this patch

eutro
---
 evaluator.rkt | 16 +++++++++++-----
 main.rkt      |  4 ++--
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/evaluator.rkt b/evaluator.rkt
index 3b93002..bfc8f9c 100644
--- a/evaluator.rkt
+++ b/evaluator.rkt
@@ -74,14 +74,20 @@

(define (run code definitions)
  (parameterize ([current-environment-variables (make-environment-variables)])
    (let* ((evaluator (init-evaluator definitions))
           (results (call-with-values
    (let* ([evaluator (init-evaluator definitions)]
           [results (call-with-values
                     (thunk
                      (with-handlers ([(const #t) identity])
                        (evaluator code)))
                     list))
           (stdout (get-output evaluator))
           (stderr (get-error-output evaluator)))
                     (lambda results
                       (map
                        (lambda (result)
                          (if (custom-write? result)
                              (call-in-sandbox-context evaluator (thunk (~a result)))
                              result))
                        results)))]
           [stdout (get-output evaluator)]
           [stderr (get-error-output evaluator)])
      (kill-evaluator evaluator)
      (apply values
             `(,stdout
diff --git a/main.rkt b/main.rkt
index 302c66a..e9b7186 100755
--- a/main.rkt
+++ b/main.rkt
@@ -389,7 +389,7 @@
(define (empty-string? s)
  (and (string? s) (= (string-length s) 0)))

(define (create-message-with-contents client channel message . contents)
(define ((create-message-with-contents client channel message) . contents)
  (let* ([content (apply ~a #:separator "\n"
                         (filter-not (disjoin void? http:attachment? empty-string?)
                                     contents))]
@@ -411,7 +411,7 @@
      (match-let ([(cons func content) (parse-command content)])
        (when func
          (call-with-values (thunk (func client db message content))
                            (curry create-message-with-contents client channel message)))))))
                            (create-message-with-contents client channel message)))))))

(define (init-client folder token)
  (log-r16-info "Storing tricks in ~a" folder)
-- 
2.31.0
builds.sr.ht
r16/patches/linux_buildtest.yml: SUCCESS in 1m35s

[Display custom-write? results in sandbox context][0] from [eutro][1]

[0]: https://lists.sr.ht/~williewillus/public-inbox/patches/21551
[1]: mailto:benedek.szilvasy@gmail.com

✓ #471471 SUCCESS r16/patches/linux_buildtest.yml https://builds.sr.ht/~williewillus/job/471471