Skip to content

Commit bc4a890

Browse files
authored
Merge pull request #1251 from wader/repl_input_filename
repl: Make input_filename output null instead of last filename
2 parents 8cf700b + acc350c commit bc4a890

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pkg/interp/init.jq

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ include "@config/init?";
2020
def input:
2121
def _input($opts; f):
2222
( _input_filenames
23-
| if length == 0 then error("break") end
23+
| if length == 0 then
24+
( _input_filename(null) as $_
25+
| error("break")
26+
)
27+
end
2428
| [.[0], .[1:]] as [$h, $t]
2529
| _input_filenames($t)
2630
| _input_filename(null) as $_

pkg/interp/testdata/inputs.fqtest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ fq -d mp3_frame '(.,input,input,input) | try todescription catch .' a b c
1919
"c"
2020
exitcode: 5
2121
stderr:
22-
error: c: break
22+
error: break
2323
$ fq -d mp3_frame -n '(.,inputs) | try todescription catch .' a b c
2424
"expected decode value but got: null (null)"
2525
"a"
@@ -41,7 +41,7 @@ $ fq -d mp3_frame -n '(input,input,input,input) | todescription' a b c
4141
"c"
4242
exitcode: 5
4343
stderr:
44-
error: c: break
44+
error: break
4545
$ fq -d mp3_frame input_filename
4646
"<stdin>"
4747
stdin:

0 commit comments

Comments
 (0)