Add filename/line functions to jq (fix #753)
This adds `input_filename` and `input_line_number` built-in functions
for use in, for example, `error` messages.
Example:
$ printf '{"a":1}\n{"a":2}\n' > 4.json
$ printf '{"a":"hello"}\n' > 5.json
$ ./jq '{ "file":input_filename, "line":input_line_number, "value":.a }' 4.json 5.json
{
"file": "4.json",
"line": 1,
"value": 1
}
{
"file": "4.json",
"line": 2,
"value": 2
}
{
"file": "5.json",
"line": 1,
"value": "hello"
}
This commit is contained in:
1 parent
c7f063188f
commit
d1cb8ee0ad
5 files changed
+53
No files matched your search
@@ -1173,3 +1173,12 @@ import "test_bind_order" as check; check::check
|
||||
null
|
||||
true
|
||||
|
||||
try input_filename catch .
|
||||
null
|
||||
"Unknown input filename"
|
||||
|
||||
try input_line_number catch .
|
||||
null
|
||||
"Unknown input line number"
|
||||
|
||||
|
||||
Reference in new issue
Block a user