Changeset 25810 in project


Ignore:
Timestamp:
01/14/12 20:56:25 (8 years ago)
Author:
felix winkelmann
Message:

shell 0.3: added capture form

Location:
release/4/shell
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/shell/tags/0.3/shell.scm

    r21770 r25810  
    22
    33
    4 (module shell (execute run run* shell shell shell-verbose command)
     4(module shell (execute run run* shell shell shell-verbose command capture)
    55
    66(import scheme chicken)
    7 (use extras utils data-structures)
     7(use extras utils data-structures posix)
    88
    99
     
    1717        cmds)))
    1818
    19 (define (execute cmds #!key status verbose)
     19(define (execute cmds #!key status verbose capture)
    2020  (let ((ss
    2121         (map
     
    2424              (when (or verbose (shell-verbose))
    2525                (printf "  ~A~%~!" cmd))
    26               (let ((r (system cmd)))
    27                 (cond (status r)
     26              (let ((r (if capture
     27                           (with-input-from-pipe cmd read-all)
     28                           (system cmd))))
     29                (cond ((or capture status) r)
    2830                      ((not (zero? r))
    2931                       (error
     
    3234                        cmd r))))))
    3335          cmds)))
    34     (if status (apply values ss) (void))))
     36    (if (or capture status) (apply values ss) (void))))
    3537
    3638(define-syntax run1
     
    4547(define-syntax run*
    4648  (syntax-rules ()
    47     ((_ cmd ...) (run1 (list status: #t) cmd ...))))
     49    ((_ cmd ...) (run1 '(status: #t) cmd ...))))
    4850
    4951(define-syntax shell
     
    5355       (run1 args cmd ...)))))
    5456
     57(define-syntax capture
     58  (syntax-rules ()
     59    ((_ cmd ...) (run1 '(capture: #t) cmd ...))))
     60
    5561
    5662)
  • release/4/shell/tags/0.3/shell.setup

    r21770 r25810  
    11;;;; -*- Scheme -*-
    22
    3 (compile -s shell.scm -JS -O3 -d1)
    4 (compile -s shell.import.scm -O3 -d0)
    53
    6 (install-extension
    7  'shell
    8  '("shell.so" "shell.import.so")
    9  '((version 0.2)))
     4(standard-extension 'shell 0.3)
  • release/4/shell/trunk/shell.scm

    r21770 r25810  
    22
    33
    4 (module shell (execute run run* shell shell shell-verbose command)
     4(module shell (execute run run* shell shell shell-verbose command capture)
    55
    66(import scheme chicken)
    7 (use extras utils data-structures)
     7(use extras utils data-structures posix)
    88
    99
     
    1717        cmds)))
    1818
    19 (define (execute cmds #!key status verbose)
     19(define (execute cmds #!key status verbose capture)
    2020  (let ((ss
    2121         (map
     
    2424              (when (or verbose (shell-verbose))
    2525                (printf "  ~A~%~!" cmd))
    26               (let ((r (system cmd)))
    27                 (cond (status r)
     26              (let ((r (if capture
     27                           (with-input-from-pipe cmd read-all)
     28                           (system cmd))))
     29                (cond ((or capture status) r)
    2830                      ((not (zero? r))
    2931                       (error
     
    3234                        cmd r))))))
    3335          cmds)))
    34     (if status (apply values ss) (void))))
     36    (if (or capture status) (apply values ss) (void))))
    3537
    3638(define-syntax run1
     
    4547(define-syntax run*
    4648  (syntax-rules ()
    47     ((_ cmd ...) (run1 (list status: #t) cmd ...))))
     49    ((_ cmd ...) (run1 '(status: #t) cmd ...))))
    4850
    4951(define-syntax shell
     
    5355       (run1 args cmd ...)))))
    5456
     57(define-syntax capture
     58  (syntax-rules ()
     59    ((_ cmd ...) (run1 '(capture: #t) cmd ...))))
     60
    5561
    5662)
  • release/4/shell/trunk/shell.setup

    r21770 r25810  
    11;;;; -*- Scheme -*-
    22
    3 (compile -s shell.scm -JS -O3 -d1)
    4 (compile -s shell.import.scm -O3 -d0)
    53
    6 (install-extension
    7  'shell
    8  '("shell.so" "shell.import.so")
    9  '((version 0.2)))
     4(standard-extension 'shell 0.3)
Note: See TracChangeset for help on using the changeset viewer.