#lang scheme/base (require "../maker.ss" scheme/runtime-path) (define-runtime-path my-location ".") (define extension (library (build-path my-location "ext.so") (build-path my-location "ext.c"))) (define unsafe-exec (load-extension extension)) (define (encode i) (cond ((string? i) (string->bytes/utf-8 i)) ((bytes? i) i) ((path? i) (encode (path->string i))) ((number? i) (encode (number->string i))))) (define (final-exec args) (apply unsafe-exec (map encode args))) (define (with-exec proc) (let ((args #f)) (let/ec avoid (let/ec escape (proc (λ (exe . new-args) (define path (find-executable-path exe)) (when (not path) (error "Could not find an executable for" exe)) (set! args (list* path exe new-args)) (escape))) (avoid)) (when args (final-exec args))))) (provide with-exec)