create_gino.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /bin/sh
  2. ## Creates gino functions by querying ginsh
  3. # Copyright (C) 2002 by Peter J. Gawthrop
  4. prefix="g_" # Prefix function names by this
  5. subdir=${prefix}funs # Where the generated functions live
  6. ginsh="/usr/bin/ginsh" # Location of ginsh
  7. create_fun() {
  8. funname=${prefix}$1
  9. filename=${funname}.m
  10. ## Creates an octave function
  11. echo Creating ${subdir}/${filename}
  12. ## Find usage string
  13. usage=`echo "?$1" | ginsh | head -1`
  14. ## The octave function
  15. cat<<EOF > ${subdir}/${filename}
  16. function res = ${funname} (arg1,arg2,arg3)
  17. ## usage: res = ${prefix}${usage}
  18. ## Generated by create_gino.sh on `date`
  19. ## DO NOT EDIT ME
  20. if nargin<1
  21. arg1 = "";
  22. endif
  23. if nargin<2
  24. arg2 = "";
  25. endif
  26. if nargin<3
  27. arg3 = "";
  28. endif
  29. res = gino("$1", arg1, arg2, arg3);
  30. endfunction
  31. EOF
  32. }
  33. create_readme() {
  34. cat > ${subdir}/README <<EOF
  35. These files were generated automatically by create_gino.sh
  36. on `date`.
  37. DO NOT EDIT THEM
  38. EOF
  39. }
  40. ## Find available ops
  41. ops=`echo "??" | ginsh | gawk '{if(i++==1) {gsub(",",""); print $0}}'`
  42. ## Does ginsh exist?
  43. if [ -x "${ginsh}" ]; then
  44. echo $ginsh exists - ok
  45. else
  46. echo $ginsh does not exist, exiting
  47. exit
  48. fi
  49. ## Create the corresponding octave funs.
  50. mkdir -p ${subdir}
  51. create_readme;
  52. for op in ${ops}; do
  53. create_fun ${op}
  54. done