Skip to content

Commit

Permalink
repl: Give error if repl is used in non-repl mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 12, 2021
1 parent ec98fd3 commit 44d8b66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/interp/interp.jq
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,11 @@ def _repl_iter($opts): _repl($opts);
def _repl_iter: _repl({});

# just gives error, call appearing last will be renamed to _repl_iter
def repl($_): error("repl must be last");
def repl: error("repl must be last");
def repl($_):
if options.repl then error("repl must be last")
else error("repl can't be used in non-repl mode")
end;
def repl: repl(null);


def _cli_expr_on_error:
Expand Down
4 changes: 4 additions & 0 deletions pkg/interp/testdata/repl.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ $ fq -i '[1,2,3]'
[1,2,3]
> [number, ...][3]> ^D
[number, ...][3]> ^D
$ fq -n repl
exitcode: 5
stderr:
error: repl can't be used in non-repl mode

0 comments on commit 44d8b66

Please sign in to comment.