guile-tools.in 2.8 KB

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