root/lang/scheme/gauche-shell/trunk/shell.scm @ 9601

Revision 9601, 0.7 kB (checked in by hayamiz, 7 years ago)

gauche-shell: initial import

Line 
1;; -*- coding: utf-8 mode: scheme -*-
2
3;;; This is a library to write a shell script with gauche.
4
5(define-module shell)
6(select-module shell)
7
8(use srfi-1)
9(use file.util)
10(use gauche.collection)
11(use gauche.process)
12(export pwd ls
13        $ command)
14
15
16
17(define pwd current-directory)
18(define-macro ($ arg)
19  `(sys-getenv
20    ,(cond
21      ((string? arg) arg)
22      ((symbol? arg) (symbol->string arg))
23      ((number? arg) (number->string arg))
24      (else (x->string arg)))))
25
26(define (ls . rest)
27  (remove #/^\.{1,2}$/
28          (if (null? rest)
29              (directory-list (pwd))
30              (apply directory-list rest))))
31
32(define-macro (command com . args)
33  `(process-output->string-list
34    '(,(x->string com)
35      ,@(map x->string args))))
36
37(provide "shell")
Note: See TracBrowser for help on using the browser.