1
1
mirror of https://github.com/wader/fq.git synced 2024-11-28 03:02:55 +03:00

Merge pull request #95 from wader/interp-fix-stdin-decode-group-error

interp: Fix handling of group decode error from stdin
This commit is contained in:
Mattias Wadman 2022-01-23 13:30:53 +01:00 committed by GitHub
commit 9d7ea7ad25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -47,16 +47,17 @@ def input:
| [.[0], .[1:]] as [$h, $t]
| _input_filenames($t)
| _input_filename(null) as $_
| ($h // "<stdin>") as $name
| $h
| try
# null input here means stdin
( open
| _input_filename($h // "<stdin>") as $_
| _input_filename($name) as $_
| .
)
catch
( . as $err
| _input_io_errors(. += {($h): $err}) as $_
| _input_io_errors(. += {($name): $err}) as $_
| $err
| (_error_str | printerrln)
, _input($opts; f)
@ -64,8 +65,8 @@ def input:
| try f
catch
( . as $err
| _input_decode_errors(. += {($h): $err}) as $_
| [ "\($h): \($opts.decode_format)"
| _input_decode_errors(. += {($name): $err}) as $_
| [ "\($name): \($opts.decode_format)"
, if $err | type == "string" then ": \($err)"
# TODO: if not string assume decode itself failed for now
else ": failed to decode (try -d FORMAT)"

View File

@ -93,3 +93,9 @@ $ fq -i -s -d raw . /a /b /c
"raw"
"raw"
[raw, ...][0:3]> ^D
$ fq
exitcode: 4
stdin:
test
stderr:
error: <stdin>: probe: failed to decode (try -d FORMAT)