diff --git a/pkg/interp/funcs.go b/pkg/interp/funcs.go index 0e206782..3d8813bc 100644 --- a/pkg/interp/funcs.go +++ b/pkg/interp/funcs.go @@ -34,7 +34,7 @@ import ( // TODO: make it nicer somehow? generate generators? remove from struct? func (i *Interp) makeFunctions() []Function { fs := []Function{ - {[]string{"readline"}, 0, 2, i.readline, nil}, + {[]string{"_readline"}, 0, 2, i.readline, nil}, {[]string{"eval"}, 1, 2, nil, i.eval}, {[]string{"stdin"}, 0, 0, nil, i.makeStdioFn(i.os.Stdin())}, {[]string{"stdout"}, 0, 0, nil, i.makeStdioFn(i.os.Stdout())}, diff --git a/pkg/interp/interp.jq b/pkg/interp/interp.jq index 4b290856..bf8fcd5d 100644 --- a/pkg/interp/interp.jq +++ b/pkg/interp/interp.jq @@ -330,7 +330,7 @@ def _repl($opts): #:: a|(Opts) => @ def _read_expr: # both _prompt and _complete want arrays ( . as $c - | readline(_prompt; "_complete") + | _readline(_prompt; "_complete") | if trim == "" then $c | _read_expr end @@ -345,7 +345,7 @@ def _repl($opts): #:: a|(Opts) => @ # TODO: nicer way to set filename for error message catch (. | .filename = "repl") | if _query_pipe_last | _query_is_func("repl") then - ( _query_slurp_wrap(_query_func_rename("_repl_iter")) + ( _query_slurp_wrap(_query_func_rename("_repl_slurp")) | _query_tostring as $wrap_expr | $c | _repl_eval($wrap_expr) @@ -361,7 +361,7 @@ def _repl($opts): #:: a|(Opts) => @ if . == "interrupt" then empty elif . == "eof" then error("break") elif _eval_is_compile_error then _repl_on_error - else error(.) + else error end ); ( _options_stack(. + [$opts]) as $_ @@ -371,13 +371,13 @@ def _repl($opts): #:: a|(Opts) => @ ) ); -def _repl_iter($opts): _repl($opts); -def _repl_iter: _repl({}); +def _repl_slurp($opts): _repl($opts); +def _repl_slurp: _repl({}); -# just gives error, call appearing last will be renamed to _repl_iter +# just gives error, call appearing last will be renamed to _repl_slurp def repl($_): if options.repl then error("repl must be last") - else error("repl can only be be used from repl") + else error("repl can only be used from interactive repl") end; def repl: repl(null); diff --git a/pkg/interp/testdata/repl.fqtest b/pkg/interp/testdata/repl.fqtest index 02e4716f..588cad7a 100644 --- a/pkg/interp/testdata/repl.fqtest +++ b/pkg/interp/testdata/repl.fqtest @@ -61,4 +61,4 @@ $ fq -i '[1,2,3]' $ fq -n repl exitcode: 5 stderr: -error: repl can only be be used from repl +error: repl can only be used from interactive repl