Skip to content

Commit

Permalink
When interpreting file, skip shebang
Browse files Browse the repository at this point in the history
  • Loading branch information
drj11 committed Apr 3, 2017
1 parent 60b5c5a commit 30cc28e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions rc.4
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,39 @@ adjust-interactive
;
adjust-vector

( SHEBANG )
( adjust addr u pair for initial shebang line. )
: shebang ( addr u -- n-addr n-u )
over c@ ( addr u c )
[char] #
<> ( addr u bf )
if
exit
then
( addr u )
swap over dup ( u addr u u )
0 do
over ( u addr l addr )
i +
c@ ( u addr l ch )
10 =
if
( :todo: reimplement using `leave` )
i min
then
loop
( u addr l )
( need to add l to addr, and subtract it from u )
tuck + ( u l n-addr )
rot rot ( n-addr u l )
- ( n-addr n- )
;

: run-args
1 argc @ < if
1 arg openr
fmapr
shebang
evaluate
then
;
Expand Down

0 comments on commit 30cc28e

Please sign in to comment.