summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorEmanuele Torre <torreemanuele6@gmail.com>2023-12-13 16:38:18 +0100
committerGitHub <noreply@github.com>2023-12-13 16:38:18 +0100
commit5d95791a6795bfc44380c2e6e343ee66dd891e8b (patch)
treeae9abaa7bea2f80012ce283e3c2d67ec21fb82cd /docs
parent511d50b15b0a903639874e933d941bad50de6652 (diff)
lexer: temporarily revert #\ patch; keep CR in comment bug fix
This commit temporarily reverts the commit that allows #\ "tcl-style" comments everywhere and documents them, for the 1.7.1 patch release cca1f7d18f2fa6721952645821ae429a0166d7e4. \r is removed from the list of characters not allowed in a comment to preserve that bugfix.
Diffstat (limited to 'docs')
-rw-r--r--docs/content/manual/manual.yml64
1 files changed, 1 insertions, 63 deletions
diff --git a/docs/content/manual/manual.yml b/docs/content/manual/manual.yml
index b8b1a1e6..bb98506d 100644
--- a/docs/content/manual/manual.yml
+++ b/docs/content/manual/manual.yml
@@ -229,7 +229,7 @@ sections:
* `-f filename` / `--from-file filename`:
Read filter from the file rather than from a command line, like
- awk's -f option.
+ awk's -f option. You can also use '#' to make comments.
* `-L directory`:
@@ -3537,68 +3537,6 @@ sections:
(.posts[] | select(.author == "stedolan") | .comments) |=
. + ["terrible."]
- - title: Comments
-
- body: |
-
- You can write comments in your jq filters using `#`.
-
- A `#` character (not part of a string) starts a comment.
- All characters from `#` to the end of the line are ignored.
-
- If the end of the line is preceded by an odd number of backslash
- characters, the following line is also considered part of the
- comment and is ignored.
-
- For example, the following code outputs `[1,3,4,7]`
-
- [
- 1,
- # foo \
- 2,
- # bar \\
- 3,
- 4, # baz \\\
- 5, \
- 6,
- 7
- # comment \
- comment \
- comment
- ]
-
- Backslash continuing the comment on the next line can be useful
- when writing the "shebang" for a jq script:
-
- #!/bin/sh --
- # sum - Output the sum of the given arguments (or stdin)
- # usage: sum [numbers...]
- # \
- exec jq --args -MRnf "$0" -- "$@"
-
- $ARGS.positional |
- reduce (
- if . == []
- then inputs
- else .[]
- end |
- . as $dot |
- try tonumber catch false |
- if not or isnan then
- @json "sum: Invalid number \($dot).\n" | halt_error(1)
- end
- ) as $n (0; . + $n)
-
- The `exec` line is considered a comment by jq, so it is ignored.
- But it is not ignored by `sh`, since in `sh` a backslash at the
- end of the line does not continue the comment.
- With this trick, when the script is invoked as `sum 1 2`,
- `/bin/sh -- /path/to/sum 1 2` will be run, and `sh` will then
- run `exec jq --args -MRnf /path/to/sum -- 1 2` replacing itself
- with a `jq` interpreter invoked with the specified options (`-M`,
- `-R`, `-n`, `--args`), that evaluates the current file (`$0`),
- with the arguments (`$@`) that were passed to `sh`.
-
- title: Modules
body: |