temporarily disable elisp exception tests
[bpt/guile.git] / meta / guild.in
CommitLineData
6d66647d
AW
1#!/bin/sh
2# -*- scheme -*-
d80b6acf 3exec ${GUILE:-@installed_guile@} $GUILE_FLAGS -e '(@@ (guild) main)' -s "$0" "$@"
6d66647d
AW
4!#
5
b8b06598 6;;;; guild --- running scripts bundled with Guile
23044464 7;;;; Andy Wingo <wingo@pobox.com> --- April 2009
6d66647d 8;;;;
d80b6acf 9;;;; Copyright (C) 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
6d66647d
AW
10;;;;
11;;;; This library is free software; you can redistribute it and/or
12;;;; modify it under the terms of the GNU Lesser General Public
13;;;; License as published by the Free Software Foundation; either
53befeb7 14;;;; version 3 of the License, or (at your option) any later version.
6d66647d
AW
15;;;;
16;;;; This library is distributed in the hope that it will be useful,
17;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19;;;; Lesser General Public License for more details.
20;;;;
21;;;; You should have received a copy of the GNU Lesser General Public
53befeb7
NJ
22;;;; License along with this library; if not, write to the Free
23;;;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;;;; Boston, MA 02110-1301 USA
6d66647d 25
b8b06598 26(define-module (guild)
9228f9eb 27 #:use-module (ice-9 getopt-long)
f4a76a31 28 #:use-module (ice-9 command-line)
92a70bcf 29 #:autoload (ice-9 format) (format))
2b4b555b 30
54b38caf
LC
31;; Hack to provide scripts with the bug-report address.
32(module-define! the-scm-module
33 '%guile-bug-report-address
34 "@PACKAGE_BUGREPORT@")
35
36
38a73781
AW
37(define *option-grammar*
38 '((help (single-char #\h))
39 (version (single-char #\v))))
40
0f6611fb 41(define (display-version)
0d2e3fc1
LC
42 (version-etc "@PACKAGE_NAME@"
43 (version)
f4a76a31
AW
44 #:command-name "guild"
45 #:license *LGPLv3+*))
0f6611fb 46
6d66647d 47(define (find-script s)
9805ffda 48 (resolve-module (list 'scripts (string->symbol s)) #:ensure #f))
6d66647d
AW
49
50(define (main args)
073167ef 51 (if (defined? 'setlocale)
e2c6bf38
LC
52 (catch 'system-error
53 (lambda ()
54 (setlocale LC_ALL ""))
55 (lambda args
56 (format (current-error-port)
57 "warning: failed to install locale: ~a~%"
58 (strerror (system-error-errno args))))))
073167ef 59
f4a76a31
AW
60 (let* ((options (getopt-long args *option-grammar*
61 #:stop-at-first-non-option #t))
62 (args (option-ref options '() '())))
9228f9eb
NJ
63 (cond
64 ((option-ref options 'help #f)
f4a76a31 65 (apply (module-ref (resolve-module '(scripts help)) 'main) args)
9228f9eb
NJ
66 (exit 0))
67 ((option-ref options 'version #f)
68 (display-version)
69 (exit 0))
f4a76a31
AW
70 ((find-script (if (null? args) "help" (car args)))
71 => (lambda (mod)
72 (exit (apply (module-ref mod 'main) (if (null? args)
73 '()
74 (cdr args))))))
9228f9eb 75 (else
f4a76a31
AW
76 (format (current-error-port)
77 "guild: unknown script ~s~%" (car args))
78 (format (current-error-port)
79 "Try `guild help' for more information.~%")
80 (exit 1)))))