mirror of
https://github.com/kanaka/mal.git
synced 2024-11-11 00:52:44 +03:00
c9de2e82ed
- tests/docker/Dockerfile: specifies full docker image containing all tools/languages (except matlab). - tests/docker-build.sh: build above image. - tests/docker-run.sh: launch above image. Example: ./tests/docker-run.sh make test^js^step2 - Various fixes across multiple languages: - Unicode fixes for bash and R on Ubuntu Utopic - readline history fixes for when ~/.mal-history is not available or readable/writable. No fatal errors. - fixes to work with perl 5.20 (and still perl 5.18)
37 lines
893 B
Racket
37 lines
893 B
Racket
#lang racket
|
|
|
|
(provide readline)
|
|
|
|
(require (prefix-in readline: readline/readline))
|
|
|
|
(require "types.rkt")
|
|
|
|
(define history-loaded #f)
|
|
(define HISTORY-FILE (format "~a/.mal-history" (find-system-path 'home-dir)))
|
|
|
|
(define (load-history path)
|
|
(with-handlers
|
|
([exn:fail? (lambda (e) #t)])
|
|
(map
|
|
(lambda (line) (readline:add-history line))
|
|
(string-split
|
|
(port->string (open-input-file path))
|
|
#px"\n"))))
|
|
|
|
(define (readline prompt)
|
|
(when (not history-loaded)
|
|
(set! history-loaded #t)
|
|
(load-history HISTORY-FILE))
|
|
(let ([line (readline:readline prompt)])
|
|
(if (eq? eof line)
|
|
nil
|
|
(begin
|
|
(readline:add-history line)
|
|
(with-handlers
|
|
([exn:fail? (lambda (e) #t)])
|
|
(with-output-to-file
|
|
HISTORY-FILE
|
|
(lambda () (printf "~a~n" line))
|
|
#:exists 'append))
|
|
line))))
|