summaryrefslogtreecommitdiff
path: root/Com/Simatime/Shell.scm
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-11-23 15:59:08 -0800
committerBen Sima <ben@bsima.me>2019-11-23 15:59:08 -0800
commitcc64fa01e9bae297915906a03f85fe50be384990 (patch)
tree0edce8775852170464cad7408c3c81dec8ad9bf6 /Com/Simatime/Shell.scm
parentcb6147436f5cdc42622e849cfd6612261704b839 (diff)
Capitalize all Scheme and Haskell modules
Diffstat (limited to 'Com/Simatime/Shell.scm')
-rw-r--r--Com/Simatime/Shell.scm34
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..b99e5cd
--- /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))