diff options
author | Ben Sima <ben@bsima.me> | 2019-11-01 14:24:24 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-11-01 14:25:49 -0700 |
commit | 9756eb0806aef63137ed53c7f78eee13aa3db9d7 (patch) | |
tree | 0c3bf0becc08e37386109ff8c518fa442df6266b /com/simatime/shell.scm | |
parent | 0a6fd40946f72e9995ca04b05d7556bf20585d4f (diff) |
add buildHaskellApp nix function
Diffstat (limited to 'com/simatime/shell.scm')
-rw-r--r-- | com/simatime/shell.scm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/com/simatime/shell.scm b/com/simatime/shell.scm new file mode 100644 index 0000000..7c6bb5c --- /dev/null +++ b/com/simatime/shell.scm @@ -0,0 +1,34 @@ +(define-module (com simatime shell) + #:use-module ((ice-9 popen) #:prefix popen/) + #:use-module ((ice-9 rdelim) #:prefix rdelim/) + #:use-module ((ice-9 ftw) #:prefix ftw/) + #:export (exec + stream + pwd + ls + cd)) + +(define (exec cmd) + (let* ((port (popen/open-input-pipe cmd)) + (ret (read port))) + (popen/close-pipe port) + ret)) + +(define (stream cmd) + (let* ((port (popen/open-input-pipe cmd)) + (_ (setvbuf port 'none)) + (ret (rdelim/read-string port))) + (flush-all-ports) + (popen/close-pipe port) + ret)) + +(define (pwd) + (regexp-substitute/global + #f "/home/ben" (getcwd) 'pre "~" 'post)) + +(define (ls) + (ftw/scandir (getcwd))) + +(define (cd path) + (chdir path) + (ls)) |