Skip to content

Commit ee1c6be

Browse files
committed
docs: document JSON_BASH_GREP envar in README
1 parent 4f1e99a commit ee1c6be

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ to find where it is).
176176
1. [Security and correctness](#security-and-correctness)
177177
1. [`jb-cat`, `jb-echo`, `jb-stream` utility programs](#jb-cat-jb-echo-jb-stream-utility-programs)
178178
1. [Streaming output](#streaming-output)
179+
1. [Configuring environment variables](#configuring-environment-variables)
179180

180181
These examples mostly use `jb`, which is the `json.bash` library run as a
181182
stand-alone program. From within a bash script you get better performance by
@@ -1010,6 +1011,30 @@ inputs, even when backtracking and matched-region output are disabled.
10101011
The full syntax of `jb` arguments is documented in a (pseudo) grammar in
10111012
[hack/syntax_patterns.bash](hack/syntax_patterns.bash).
10121013

1014+
### Configuring environment variables
1015+
1016+
`json.bash` can be configured by setting certain environment variables:
1017+
1018+
#### `JSON_BASH_GREP`
1019+
1020+
The command(s) to run to start the JSON validator grep co-process.
1021+
1022+
Default: `ggrep:grep`
1023+
1024+
`json.bash` uses a
1025+
[regular expression to validate JSON data](./hack/syntax_patterns.bash). It uses
1026+
a GNU grep co-process to validate lines of JSON data using this regex
1027+
(specifically GNU grep, because it's a [PCRE] expression).
1028+
1029+
This environment variable contains a list of command names or absolute paths to
1030+
execute. Multiple commands are separated with `:`. The first command that exists
1031+
is used, so the list can contain missing commands, so long as one exists.
1032+
1033+
The default of `ggrep:grep` means `ggrep` will be used if it's available,
1034+
otherwise `grep`.
1035+
1036+
[PCRE]: https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions
1037+
10131038
## Background & performance notes
10141039

10151040
Quite reasonably, you may be wondering why anyone would use Bash to implement a

0 commit comments

Comments
 (0)