using-system.scm 694 B

1234567891011121314151617181920
  1. ;; This code is taken from somewhere, I think from the GNU Guile mailing
  2. ;; list. Not mine.
  3. ;; https://www.gnu.org/software/guile/manual/html_node/Pipes.html
  4. (system "diff -ua /tmp/file1 /tmp/file2 | wc -c")
  5. (define (diffsize f1 f2)
  6. (receive (from to pids)
  7. (pipeline (list (list "/usr/bin/diff" "-ua" f1 f2)
  8. (list "/usr/bin/wc" "-c")))
  9. (let ((rval (cons f2 (string->number
  10. (string-delete #\newline
  11. (read-delimited " " from)))))
  12. (xvals (map (compose status:exit-val cdr waitpid) pids)))
  13. (close to)
  14. (close from)
  15. (format #t "Exit values: ~a\n" xvals)
  16. rval)))