Commit | Line | Data |
---|---|---|
7e1cd073 TTN |
1 | #!/bin/sh |
2 | ||
f24ceff2 | 3 | # Copyright (C) 2001, 2003, 2006, 2008 Free Software Foundation, Inc. |
7e1cd073 TTN |
4 | # |
5 | # This program is free software; you can redistribute it and/or | |
6 | # modify it under the terms of the GNU General Public License as | |
7 | # published by the Free Software Foundation; either version 2, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | # General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this software; see the file COPYING. If not, write to | |
92205699 MV |
17 | # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | # Boston, MA 02110-1301 USA | |
7e1cd073 | 19 | |
de057fdc | 20 | # Usage: See `help' func below. |
7e1cd073 TTN |
21 | # |
22 | # TODO | |
23 | # - handle pre-install invocation | |
24 | # - "full" option processing (but see comment below) | |
25 | # | |
26 | # Author: Thien-Thi Nguyen | |
27 | ||
de057fdc TTN |
28 | help () |
29 | { | |
30 | cat <<EOF | |
31 | Usage: guile-tools --version | |
32 | guile-tools --help | |
33 | guile-tools [OPTION] PROGRAM [ARGS] | |
34 | ||
35 | If PROGRAM is "list" or omitted, display contents of scripts dir, otherwise | |
36 | PROGRAM is run w/ ARGS. Options (only one of which may be used at a time): | |
37 | --scriptsdir DIR -- Look in DIR for scripts | |
38 | --guileversion VERS -- Look in $pkgdatadir/VERS/scripts for scripts | |
d902b02a | 39 | --source -- Display PROGRAM source (ignore ARGS) to stdout |
de057fdc TTN |
40 | |
41 | Default scripts dir: $default_scriptsdir | |
42 | EOF | |
43 | } | |
44 | ||
7e1cd073 | 45 | prefix="@prefix@" |
f24ceff2 | 46 | datarootdir="@datarootdir@" |
7e1cd073 | 47 | pkgdatadir="@datadir@/@PACKAGE@" |
223a9f7c | 48 | guileversion="@GUILE_EFFECTIVE_VERSION@" |
7e1cd073 TTN |
49 | default_scriptsdir=$pkgdatadir/$guileversion/scripts |
50 | ||
51 | # pre-install invocation frob | |
52 | mydir=`dirname $0` | |
53 | if [ -d "$mydir/scripts" -a -f "$mydir/scripts/Makefile.am" ] ; then | |
54 | default_scriptsdir=`(cd $mydir/scripts ; pwd)` | |
55 | fi | |
56 | ||
7e1cd073 TTN |
57 | # option processing -- basically, you can override either the script dir |
58 | # completely, or just the guile version. we choose implementation simplicity | |
59 | # over orthogonality. | |
60 | ||
de057fdc TTN |
61 | case x"$1" in |
62 | x--version) | |
7e1cd073 TTN |
63 | echo $0 $guileversion |
64 | exit 0 | |
de057fdc TTN |
65 | ;; |
66 | x--help) | |
7e1cd073 TTN |
67 | help |
68 | exit 0 | |
de057fdc TTN |
69 | ;; |
70 | esac | |
7e1cd073 TTN |
71 | |
72 | if [ x"$1" = x--scriptsdir ] ; then | |
73 | user_scriptsdir=$2 | |
74 | shift | |
75 | shift | |
76 | elif [ x"$1" = x--guileversion ] ; then | |
77 | user_scriptsdir=$pkgdatadir/$2/scripts | |
78 | shift | |
79 | shift | |
80 | fi | |
81 | ||
82 | scriptsdir=${user_scriptsdir-$default_scriptsdir} | |
83 | ||
84 | if [ ! -d $scriptsdir ] ; then | |
85 | echo $0: no such directory: $scriptsdir | |
86 | exit 1 | |
87 | fi | |
88 | ||
de057fdc TTN |
89 | if [ x"$1" = x -o x"$1" = xlist ] ; then |
90 | ls $scriptsdir | |
91 | exit 0 | |
7e1cd073 TTN |
92 | fi |
93 | ||
d902b02a TTN |
94 | if [ x"$1" = x--source ] ; then |
95 | if [ x"$2" = x ] ; then echo $0: need to specify program ; exit 1 ; fi | |
96 | if [ -x $scriptsdir/$2 ] ; then | |
97 | cat $scriptsdir/$2 | |
98 | exit 0 | |
99 | else | |
100 | echo $0: no such program: $2 | |
101 | exit 1 | |
102 | fi | |
103 | fi | |
104 | ||
7e1cd073 TTN |
105 | program=$scriptsdir/$1 |
106 | shift | |
107 | ||
108 | if [ -x $program ] ; then | |
109 | exec $program "$@" | |
110 | else | |
111 | echo $0: no such program: $program | |
112 | exit 1 | |
113 | fi | |
114 | ||
115 | # guile-tools ends here |