seancribbs/neotoma — pull request #23 by seth (2013-04-23 02:13:53+00:00)
Title: Fix use of neotoma as an escript

When I try to run neotoma as an escript, I get the following error trace:

```
[strobos] src/neotoma: make clean
==> neotoma (clean)
[strobos] src/neotoma: make
==> neotoma (compile)
Compiled src/neotoma.erl
Compiled src/neotoma_peg.erl
Compiled src/neotoma_parse.erl
[strobos] src/neotoma: make escript
==> neotoma (escriptize)
[strobos] src/neotoma: ./neotoma extra/arithmetic.peg -output .
escript: exception error: no match of right hand side value {error,enotdir}
in function neotoma:file/2 (src/neotoma.erl, line 46)
in call from escript:run/2 (escript.erl, line 741)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_it/1
in call from init:start_em/1
```

This is on OS X with Erlang R15B03:
```
Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]

Eshell V5.9.3.1 (abort with ^G)

uname -a
Darwin strobos.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
```

I think the issue is that, at least in more recent versions of Erlang, functions like `code:priv_dir` and `code:where_is_file` return rather surprising results when run in escript context. For example, when I print out code:priv_dir in the escript I see: `"/Users/seth/src/neotoma/neotoma/neotoma/priv"` and where_is_file similarly yo dawg's the project name.

This patch uses escript:script_name when in escript context to get the right code path.