Outdated egg!

This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for the CHICKEN 4 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

  1. Outdated egg!
  2. Runcmd
    1. Introduction
    2. run
    3. run*
    4. run-verbose
    5. dry-run
    6. Authors
    7. License
    8. Version History

Runcmd

Introduction

Convenience macros for running shell commands.

run

 [syntax] (run COMMAND)
 [syntax] (run < COMMAND)
 [syntax] (run > THUNK COMMAND)

Runs COMMAND as a shell command using the system(3) library function. COMMAND should be a list where each list-element will be converted to a string and the resulting strings concatenated, separated by a single space character. COMMAND is implicitly quasi-quoted - subexpressions preceded by , or ,@ are evaluated. Sub-lists in the command are flattened and spliced into the result sequence. Quoted sub-expressions are enclosed in single quotes ('...'). Note that the characters ' ( ) { } [ ] , ; ` " | are treated specially by the Scheme reader and thus should be enclosed in double quotes (see the examples section).

If the command exists with a non-zero status code, an exception of the kinds (exn runcmd) is signalled.

If the command is preceded by <, then run returns a string containing the output of the command, with any trailing newline character removed. If the command is preceded by >, then the first argument is evaluated and COMMAND is executed with its standard input replaced by any output written to the value returned by (current-output-port) during execution of the zero argument procedure THUNK:

 (run > (cut print "one\ntwo") (tac))

prints

 two
 one

run*

 [syntax] (run* COMMAND)

Similar to run, but returns the status code of the shell command (without signalling an exception in case the status is nonzero).

run-verbose

 [parameter] run-verbose

If true, then each command executed by run[*] is printed to the port returned by (current-output-port).

dry-run

 [parameter] dry-run

If true, then commands are not executed and treated as executing successfully.

Authors

felix winkelmann

License

Copyright (c) 2007, Felix L. Winkelmann
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
  Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
  Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
  Neither the name of the author nor the names of its contributors may be
    used to endorse or promote products derived from this software without
    specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Version History

0.2
added > [suggested by Ivan Raikov]
0.1
initial release