guile-tools.in 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/sh
  2. # Copyright (C) 2001, 2003, 2006, 2008 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. datarootdir="@datarootdir@"
  41. pkgdatadir="@datadir@/@PACKAGE@"
  42. guileversion="@GUILE_EFFECTIVE_VERSION@"
  43. default_scriptsdir=$pkgdatadir/$guileversion/scripts
  44. # pre-install invocation frob
  45. mydir=`dirname $0`
  46. if [ -d "$mydir/scripts" -a -f "$mydir/scripts/Makefile.am" ] ; then
  47. default_scriptsdir=`(cd $mydir/scripts ; pwd)`
  48. fi
  49. # option processing -- basically, you can override either the script dir
  50. # completely, or just the guile version. we choose implementation simplicity
  51. # over orthogonality.
  52. case x"$1" in
  53. x--version)
  54. echo $0 $guileversion
  55. exit 0
  56. ;;
  57. x--help)
  58. help
  59. exit 0
  60. ;;
  61. esac
  62. if [ x"$1" = x--scriptsdir ] ; then
  63. user_scriptsdir=$2
  64. shift
  65. shift
  66. elif [ x"$1" = x--guileversion ] ; then
  67. user_scriptsdir=$pkgdatadir/$2/scripts
  68. shift
  69. shift
  70. fi
  71. scriptsdir=${user_scriptsdir-$default_scriptsdir}
  72. if [ ! -d $scriptsdir ] ; then
  73. echo $0: no such directory: $scriptsdir
  74. exit 1
  75. fi
  76. if [ x"$1" = x -o x"$1" = xlist ] ; then
  77. ls $scriptsdir
  78. exit 0
  79. fi
  80. if [ x"$1" = x--source ] ; then
  81. if [ x"$2" = x ] ; then echo $0: need to specify program ; exit 1 ; fi
  82. if [ -x $scriptsdir/$2 ] ; then
  83. cat $scriptsdir/$2
  84. exit 0
  85. else
  86. echo $0: no such program: $2
  87. exit 1
  88. fi
  89. fi
  90. program=$scriptsdir/$1
  91. shift
  92. if [ -x $program ] ; then
  93. exec $program "$@"
  94. else
  95. echo $0: no such program: $program
  96. exit 1
  97. fi
  98. # guile-tools ends here