/arc.sh

http://github.com/alimoeeny/arc · Shell · 47 lines · 33 code · 7 blank · 7 comment · 9 complexity · 9869e7ec32c843272cebd7271e976033 MD5 · raw file

  1. #!/bin/sh
  2. arc_dir=$(dirname "$(readlink "$0")")
  3. if [ "$1" = "--no-rl" ]; then
  4. shift
  5. elif [ "$(type rlwrap)" ]; then
  6. rl="rlwrap -C arc"
  7. fi
  8. # I wish there were some cleaner way to do this
  9. case "$(mzscheme --version)" in
  10. *v4.*) plt4=yes;;
  11. *v5.*) plt4=yes;; # compatible with v4 for the use in this script
  12. *) plt4=no;;
  13. esac
  14. if [ $# -gt 0 ]
  15. then repl='#f'
  16. else
  17. # It seems like there ought to be a program for determining whether standard
  18. # input is a tty, but I can't find one; so we use mzscheme instead.
  19. if [ $plt4 = yes ]
  20. then repl=$(mzscheme -e '(terminal-port? (current-input-port))')
  21. else repl=$(mzscheme -mve '(display (terminal-port? (current-input-port)))')
  22. fi
  23. fi
  24. opts="--no-init-file"
  25. if [ $plt4 = yes ]; then
  26. if [ $repl = '#t' ]
  27. then
  28. # AFAICT, there is no equivalent of --mute-banner for mzscheme v4.
  29. # Please do NOT add -r/--script here, this removes the ability to access
  30. # the Scheme REPL. See http://arclanguage.org/item?id=10356.
  31. opts="$opts --repl --load"
  32. else opts="$opts --script"
  33. fi
  34. else
  35. if [ $repl = '#t' ]
  36. then opts="$opts --mute-banner --load"
  37. else opts="$opts --script"
  38. fi
  39. fi
  40. $rl mzscheme $opts $arc_dir/as.scm $@