diff options
author | cvs2svn <admin@example.com> | 2002-08-04 00:18:34 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 2002-08-04 00:18:34 +0000 |
commit | 2f4c89c4f475d3b2c718cbd4332c650214488ff9 (patch) | |
tree | 5abd57b1ace53b0c6970da9395f15d80d5f79430 /examples/scripts | |
parent | c7743d027a335eae585335b959e483c5a6c38d36 (diff) | |
download | guile-after-hanwen-gc-change.tar.gz |
This commit was manufactured by cvs2svn to create tagafter-hanwen-gc-change
'after-hanwen-gc-change'.
Diffstat (limited to 'examples/scripts')
-rw-r--r-- | examples/scripts/.cvsignore | 2 | ||||
-rw-r--r-- | examples/scripts/Makefile.am | 25 | ||||
-rw-r--r-- | examples/scripts/README | 38 | ||||
-rwxr-xr-x | examples/scripts/check.test | 53 | ||||
-rwxr-xr-x | examples/scripts/fact | 69 | ||||
-rwxr-xr-x | examples/scripts/hello | 57 | ||||
-rw-r--r-- | examples/scripts/simple-hello.scm | 16 |
7 files changed, 0 insertions, 260 deletions
diff --git a/examples/scripts/.cvsignore b/examples/scripts/.cvsignore deleted file mode 100644 index 282522db0..000000000 --- a/examples/scripts/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/examples/scripts/Makefile.am b/examples/scripts/Makefile.am deleted file mode 100644 index 3a82dad77..000000000 --- a/examples/scripts/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -## Process this file with Automake to create Makefile.in -## -## Copyright (C) 2001 Free Software Foundation, Inc. -## -## This file is part of GUILE. -## -## GUILE is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as -## published by the Free Software Foundation; either version 2, or -## (at your option) any later version. -## -## GUILE is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public -## License along with GUILE; see the file COPYING. If not, write -## to the Free Software Foundation, Inc., 59 Temple Place, Suite -## 330, Boston, MA 02111-1307 USA - -EXTRA_DIST = README simple-hello.scm hello fact check.test - -installcheck: - srcdir=$(srcdir) GUILE_LOAD_PATH=$(top_srcdir) $(srcdir)/check.test diff --git a/examples/scripts/README b/examples/scripts/README deleted file mode 100644 index f3e965b5a..000000000 --- a/examples/scripts/README +++ /dev/null @@ -1,38 +0,0 @@ - -*- outline -*- - -* Overview - -This directory includes examples which show how to write scripts using -Guile. - -The descriptions below assume that you have a working copy of Guile -installed and available with the standard installation prefix -`/usr/local'. - -* Included Examples - - -** simple-hello.scm - - The simplest "Hello World!" program for Guile. Run it like this: - - $ guile -s simple-hello.scm - -** hello - - An advanced version of the script above, with command line handling - for the important options --help and --version. Run it like this: - - ./hello - - or - - guile -s hello - -** fact - - Command-line factorial calculator. Run it like this: - - ./fact 5 - - to calculate the factorial of 5. diff --git a/examples/scripts/check.test b/examples/scripts/check.test deleted file mode 100755 index 2a3e753d6..000000000 --- a/examples/scripts/check.test +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# must be run from this directory -guile=${GUILE-../../libguile/guile} -if [ -x $guile ] ; then - : -else - echo could not find guile interpreter. - echo '(are you running this script from' `dirname $0` '?)' - echo GUILE env var: ${GUILE-not set} - exit 1 -fi - -if test "X$srcdir" = X; then - srcdir=. -fi - -set -e - -# -# simple-hello.scm -# -$guile -s $srcdir/simple-hello.scm > TMP -cat <<EOF | diff -u - TMP -Hello, World! -EOF -rm -f TMP - -# -# hello -# -$guile -s $srcdir/hello > TMP -echo "Hello, World!" | diff -u - TMP -rm -f TMP - -$guile -s $srcdir/hello --version > TMP -echo "hello 0.0.1" | diff -u - TMP -rm -f TMP - -$guile -s $srcdir/hello --help > TMP -cat <<EOF | diff -u - TMP -Usage: hello [options...] - --help, -h Show this usage information - --version, -v Show version information -EOF -rm -f TMP - -# -# fact -# -case `$guile -s $srcdir/fact 5` in 120) ;; *) echo $0: error: fact 5 ;; esac - -# check.test ends here diff --git a/examples/scripts/fact b/examples/scripts/fact deleted file mode 100755 index 05bcc9ffe..000000000 --- a/examples/scripts/fact +++ /dev/null @@ -1,69 +0,0 @@ -#! /usr/local/bin/guile -s -!# -;;; Commentary: - -;;; This is a command-line factorial calculator. Run like this: -;;; -;;; ./fact 5 -;;; -;;; to calculate the factorial of 5 - -;;; Author: Martin Grabmueller -;;; Date: 2001-05-29 - -;;; Code: - -(use-modules (ice-9 getopt-long)) - -;; This is the grammar for the command line synopsis we expect. -;; -(define command-synopsis - '((version (single-char #\v) (value #f)) - (help (single-char #\h) (value #f)))) - -;; Display version information and exit. -;; -(define (display-version) - (display "fact 0.0.1\n")) - -;; Display the usage help message and exit. -;; -(define (display-help) - (display "Usage: fact [options...] number\n") - (display " --help, -h Show this usage information\n") - (display " --version, -v Show version information\n")) - -;; Interpret options, if --help or --version was given, print out the -;; requested information and exit. Otherwise, calculate the factorial -;; of the argument. -;; -(define (main options) - (let ((help-wanted (option-ref options 'help #f)) - (version-wanted (option-ref options 'version #f)) - (args (option-ref options '() '()))) - (cond - ((or version-wanted help-wanted) - (if version-wanted - (display-version)) - (if help-wanted - (display-help))) - ((not (= (length args) 1)) - (display-help)) - (else - (display (fact (string->number (car args)))) - (newline))))) - -;; Calculate the factorial of n. -;; -(define (fact n) - (if (< n 2) - 1 - (* n (fact (- n 1))))) - -;; Call the main program with parsed command line options. -;; -(main (getopt-long (command-line) command-synopsis)) - -;; Local variables: -;; mode: scheme -;; End: diff --git a/examples/scripts/hello b/examples/scripts/hello deleted file mode 100755 index 01f9a6c3b..000000000 --- a/examples/scripts/hello +++ /dev/null @@ -1,57 +0,0 @@ -#! /usr/local/bin/guile -s -!# -;;; Commentary: - -;;; This is the famous Hello-World-program, written for Guile. It is a -;;; little bit enhanced in that it understands the command line options -;;; `--help' (-h) and `--version' (-v), which print a short usage -;;; decription or version information, respectively. - -;;; Author: Martin Grabmueller -;;; Date: 2001-05-29 - -;;; Code: - -(use-modules (ice-9 getopt-long)) - -;; This is the grammar for the command line synopsis we expect. -;; -(define command-synopsis - '((version (single-char #\v) (value #f)) - (help (single-char #\h) (value #f)))) - -;; Display version information. -;; -(define (display-version) - (display "hello 0.0.1\n")) - -;; Display the usage help message. -;; -(define (display-help) - (display "Usage: hello [options...]\n") - (display " --help, -h Show this usage information\n") - (display " --version, -v Show version information\n")) - -;; Interpret options, if --help or --version was given, print out the -;; requested information and exit. Otherwise, print the famous -;; message. -;; -(define (main options) - (let ((help-wanted (option-ref options 'help #f)) - (version-wanted (option-ref options 'version #f))) - (if (or version-wanted help-wanted) - (begin - (if version-wanted - (display-version)) - (if help-wanted - (display-help))) - (begin - (display "Hello, World!") (newline))))) - -;; Call the main program with parsed command line options. -;; -(main (getopt-long (command-line) command-synopsis)) - -;; Local variables: -;; mode: scheme -;; End: diff --git a/examples/scripts/simple-hello.scm b/examples/scripts/simple-hello.scm deleted file mode 100644 index b46bc36ff..000000000 --- a/examples/scripts/simple-hello.scm +++ /dev/null @@ -1,16 +0,0 @@ -;;; Commentary: - -;;; This is the famous Hello-World-program, written for Guile. -;;; -;;; For an advanced version, see the script `hello' in the same -;;; directory. - -;;; Author: Martin Grabmueller -;;; Date: 2001-05-29 - -;;; Code: - -(display "Hello, World!") -(newline) - -;;; End of file. |