PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/bsh/commands/source.bsh

#
Unknown | 23 lines | 19 code | 4 blank | 0 comment | 0 complexity | df72bd369409d2aef3fc9cc7c0c4109d MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /**
  2. Read filename into the interpreter and evaluate it in the current
  3. namespace. Like the Bourne Shell "." command.
  4. This command acts exactly like the eval() command but reads from a file
  5. or URL source.
  6. @see eval() for more information.
  7. @throws bsh.EvalError or bsh.TargetError on errors in the sourced script.
  8. */
  9. bsh.help.source = "usage: source( filename | URL )";
  10. Object source( String filename ) {
  11. // source with filename preserves file name in error messages
  12. return this.interpreter.source( filename, this.caller.namespace );
  13. }
  14. Object source( URL url ) {
  15. return this.interpreter.eval(
  16. new InputStreamReader(url.openStream()), this.caller.namespace,
  17. "URL: "+url.toString()
  18. );
  19. }