Skip to content

Commit

Permalink
interp: _readline: Use _repeat_break, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 23, 2021
1 parent 0cce5ec commit cf26b1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/interp/repl.jq
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ def _repl_eval($expr): _eval($expr; "repl"; _repl_display; _repl_on_error; _repl
# run read-eval-print-loop
def _repl($opts): #:: a|(Opts) => @
def _read_expr:
# both _prompt and _complete want arrays
( . as $c
| _readline(_prompt; {complete: "_complete", timeout: 0.5})
| if trim == "" then
$c | _read_expr
end
_repeat_break(
# both _prompt and _complete want input arrays
( _readline(_prompt; {complete: "_complete", timeout: 0.5})
| if trim == "" then empty
else (., error("break"))
end
)
);

def _repl_loop:
( . as $c
| try
Expand Down
3 changes: 3 additions & 0 deletions pkg/interp/testdata/repl.fqtest
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
$ fq -i
null>
null> .
null
null> 1+1
2
null> (
Expand Down

0 comments on commit cf26b1f

Please sign in to comment.