summaryrefslogtreecommitdiff
path: root/bs/shell.scm
diff options
context:
space:
mode:
Diffstat (limited to 'bs/shell.scm')
-rw-r--r--bs/shell.scm32
1 files changed, 32 insertions, 0 deletions
diff --git a/bs/shell.scm b/bs/shell.scm
new file mode 100644
index 0000000..8578f72
--- /dev/null
+++ b/bs/shell.scm
@@ -0,0 +1,32 @@
+(define-module (bs 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 getcwd)
+
+(define (ls)
+ (ftw/scandir (getcwd)))
+
+(define (cd path)
+ (chdir path)
+ (ls))