104 Commits
Author SHA1 Message Date
qodelicious 49fbca1242 docs: explain that semicolons separate function arguments (#3685)
The manual's "Defining Functions" section shows only one-argument
functions, so it never says how to pass more than one. This adds a short
paragraph: arguments are separated by `;` in both `def f(a; b):` and
`f(.x; .y)`, and `f(.x, .y)` instead calls a one-argument `f` with the
filter `.x, .y`. It also adds an example for each. `tests/man.test` and
`jq.1.prebuilt` are regenerated.

Fixes #2163
2026-10-22 20:24:55 +02:00
qodelicious e440cccc0a docs: fix arithmetic update-assignment equivalence (#3682)
The manual said `a op= b` is equivalent to `a |= . op b`. It is actually
equivalent to `(b as $b | a |= . op $b)`: the right-hand side gets `.`
as input, not the value being updated, and each value it outputs gives a
separate result.

This updates the description and adds two examples, `.a += .b` and `.a
+= (1,2)`. `tests/man.test` and `jq.1.prebuilt` are regenerated.

Fixes #2119, fixes #2407
2026-10-22 20:23:52 +02:00
qodelicious 4b45d6c1ba docs: print one example output per line in the man page (#3683) 2026-10-21 21:34:38 +09:00
Léane GRASSER 175b8e3c51 docs: update quoting rules for PowerShell 7.3+ (#3649)
The manual recommended backslash-escaped double quotes inside the jq
program for all PowerShell versions, but since PowerShell 7.3 native
command arguments are passed with standard quoting by default, so the
backslashes reach jq literally.

Describe the quoting rules separately for Unix shells and PowerShell
7.3+, for older PowerShell and Windows PowerShell, and for cmd.exe, and
update the examples to match.
2026-10-20 22:28:24 +09:00
Dmitri Vereshchagin 633ae6058a Disable colored output on a dumb terminal (#3552)
Enable colored output by default only when the TERM environment variable
is set to a value other than dumb, as git and grep do, so that users no
longer need to pass -M or set NO_COLOR on terminals that cannot display
escape sequences. Colored output is now disabled not only for TERM=dumb
but also when TERM is unset or empty. The -C option still enables colors
in all these cases. On Windows, colored output is still decided by
ANSICON and the console mode, and TERM is not checked.
2026-10-16 21:50:47 +09:00
Hugohong258 611c575a97 docs: add simple and nested update-assignment examples (#3664) 2026-10-12 00:24:32 +09:00
itchyny 17b87d25c7 Drop the date from the committed man page (#3659)
The date in the .TH line of jq.1.prebuilt changed whenever the manual was
regenerated in a new month, causing merge conflicts between pull requests
that touch the manual, and it did not reflect the release date anyway.
Generate the committed man page without a date.

Stamp the date into jq.1 at build time instead, taking it from the current
commit, or from SOURCE_DATE_EPOCH where that is set, so that release
tarballs and distribution builds still carry one and the behaviour added
in #3514 is kept. Write it in UTC and in ISO 8601 rather than the previous
"%B %Y", for which mandoc reports "cannot parse date, using it verbatim".
2026-10-08 22:16:42 +09:00
itchyny fd25c3e720 Parse the full ISO 8601 grammar in fromdateiso8601 (#3617)
`fromdateiso8601` was `strptime("%Y-%m-%dT%H:%M:%SZ") | mktime`, which
accepts only one of the many representations ISO 8601 permits. strptime
cannot be extended to cover the rest portably, since it has no specifier
for fractional seconds and glibc discards `%G` and `%V`.

Replace it with a parser in src/iso8601.c that handles basic and extended
representations, ordinal and week dates, fractional seconds, offsets and
date-only input. It uses integer arithmetic instead of `time_t`, so the
results no longer depend on the platform.

This is stricter than before. Impossible dates like `2015-02-30`, which
`mktime` used to normalize into March, and unpadded components like
`2015-3-5T6:00:00Z` are now errors. So is any trailing input, including
whitespace. Leading whitespace is rejected too; before, glibc skipped it
and macOS did not. A leap second now maps to the second before it rather
than the next minute. The error message has changed, and the result can
now be non-integer.
2026-10-08 08:24:10 +09:00
Anna Rift 41b8edfe54 Fix a handful of typos (#3605) 2026-08-24 00:06:16 +09:00
Anna Rift 4bb50d772b Fix typo 'you may wish [to] use' (#3604)
Fix all instances of the phrase "you may wish use `fabs`" -> "you may
wish _to_ use `fabs`" (emphasis mine) in the manual.
2026-08-12 21:02:39 +02:00
ded-furby 2d410d6d86 docs: clarify join behavior on objects (#3555) 2026-07-19 21:27:45 +09:00
José Joaquín Atria 88b9c4920e Fix stder typo (#3446)
The manual was missing an "r" in "stderr".
2025-12-12 10:54:39 +01:00
Jan-Piet Mens 4829059147 Add missing word in manual for rawfile (#3434) 2025-11-18 09:49:59 +09:00
TheOdd 11f43e9d93 Fixed minor typo in docs (#3359) 2025-06-30 07:31:28 +09:00
Gabriel Marin 7d8c096e48 Add trimstr/1 function (#3319) 2025-05-21 18:46:04 +09:00
Brahm Lower c350566001 Adds "toboolean" builtin function for converting strings to booleans (#2098) 2025-05-18 16:31:10 +09:00
itchyny b088e83a82 Refactor splits/2 using foreach syntax (remove private filter _nwise) (#3260)
This commit refactors `splits/2` implementation using `foreach` syntax
and reduces intermediate arrays. This refactoring removes an unnecessary
private (and undocumented) filter `_nwise` and closes #3148.
2025-05-18 08:27:44 +09:00
Thomas Sibley 931a362f8b docs: Use a better input example in the streaming section (#3322)
The introduction says all the usage examples (e.g. of truncate_stream,
etc) in the section use [0,[1]] as input, but they actually use [1,[2]].
["a",["b"]] seems better than [1,[2]] as the string values won't be
confusable with the indexes in <path>.
2025-05-14 20:46:31 +09:00
itchyny 6ce3bdf382 fix: preserve numerical precision on unary negation (#3242) 2025-02-06 07:50:21 +09:00
itchyny ce54621904 docs: mention the behavior of scan using regex with capturing groups (#3240) 2025-01-28 11:41:17 +09:00
Han Jiang da28628edd Fix redundant subexpression in Generators and iterators example in doc (#3239) 2025-01-27 19:45:27 +09:00
Michael Färber 18bd8374c1 Escape some code parts in manual. (#3184) 2025-01-25 21:55:06 +09:00
itchyny a7b22539a4 fix: make last(empty) yield no output values (#3179) 2024-11-13 20:35:50 +09:00
Thalia Archibald 32a304b912 Clarify -f argument parsing (#3199) 2024-11-09 15:48:24 +01:00
Thalia Archibald eb9bdca296 Remove outdated FIXME
This comment predates the addition of $ARGS in jq 1.6, so there was no
way to access named arguments with an invalid identifier. Rather than
forbid such names, update the manual to clarify.
2024-11-08 19:07:55 +01:00
Thalia Archibald 0558e77e8c Add --library-path long option for -L
-L is the only option without a long form.
2024-11-08 19:07:55 +01:00
itchyny 1bebd23aad add skip/2 as the counterpart to limit/2 (#3181)
I also changed the behavior of limit/2 with negative count to emit an error, like nth/2 does.
Also, I redefined nth/2 using skip/2 to minimize the impact of growth of builtin filters.
2024-10-06 08:25:38 +09:00
Nathan Baulch 860af44fee Fix typos (#3173) 2024-09-13 18:30:49 +09:00
Chris LaRose 37f4cd2648 Fix docs for strptime(fmt) (#3164) 2024-08-27 10:59:43 +09:00
Kirk McKelvey 6322b99252 fix: find and source ~/.jq file on windows (fixes #3104) (#3114) 2024-08-24 08:44:08 +09:00
fletcher gornick 0e0cdd552e feat: uri decode function (#3161) 2024-08-22 08:07:24 +09:00
myaaaaaaaaa 0b5ae30f19 Implement add/1 (#3144) 2024-08-20 21:02:24 +09:00
Nicolas Williams 6d02d53f51 Make tests pass when --disable-decnum 2024-05-15 12:48:00 -05:00
Mattias Wadman be437ec049 Add trim/0, ltrim/0 and rtrim/0 that trims leading and trailing whitespace (#3056) 2024-03-20 11:04:17 +01:00
itchyny 81f4f883ac Remove non-standard pow10 filter in favor of exp10 (#3059)
The pow10 function was a glibc extension removed in 2.27. Use exp10 filter instead.
2024-03-20 18:23:08 +09:00
J. B. RainsbergerandEmanuele Torre 92d35378ff Fix typo in documentation for map_values (#3035)
* Fix typo in documentation for map_values

"map_value(f)" -> "map_values(f)"

* map_value => map_values also in the devolpment manual

---------

Co-authored-by: Emanuele Torre <torreemanuele6@gmail.com>
2024-02-08 13:52:50 +00:00
Emanuele Torre 13e02ba348 docs: rename example jq utility to total
Apparently sum(1) is a BSD and GNU coreutil used to compute the
"16-bit BSD checksum" of a file.
2024-01-30 12:23:33 -06:00
Jonathan Chan Kwan Yin 1daabc67ed typo contruct->construct (#3017) 2024-01-25 22:21:41 +01:00
Mattias Wadman c95f6ce700 Fix "in the a search" typo (#3015)
Fixes #3014
2024-01-24 23:34:41 +01:00
Emanuele Torre 71e7bcdfc1 Revert "lexer: temporarily revert #\ patch; keep CR in comment bug fix"
This reverts commit 5d95791a67.
2024-01-16 16:08:03 -06:00
wllm-rbnt 0b922725b1 Fix typo (#3002) 2023-12-24 11:22:20 +01:00
Emanuele Torre 5d95791a67 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
cca1f7d18f.

\r is removed from the list of characters not allowed in a comment to
preserve that bugfix.
2023-12-13 16:38:18 +01:00
Jesper Rønn-Jensen 2ccab044fe chore: Improve readability (for Alternative operator '//')
The description of the Alternative operator `//` was hard for me to grasp in its wording.

I suggest dividing the looong sentence into two parts. Since it is actually an alternative formulation, the sentence can be divided into the first formulation, and the alternative formulation.
2023-12-11 11:38:54 +00:00
Emanuele Torre cca1f7d18f Comment bug fixes, and fully support Tcl-style multiline comments
* bugfix: comments were incorrectly being terminated by CR; for example
    jq -n $'1 #foo\r'
  fails to compile because the CR character terminates the comment, and
  CR is not a valid character in jq syntax.

* improvement: comments fully support Tcl-style line continuation.
  Previously this was only "supported" in `-f' scripts, whose first line
  starts with "#!", and second line starts with # and ends with \, only
  for the comment on the second line, only for one extra line.

* man: document comment syntax, which was previously undocumented.

* tests: add regression tests for the bugfix, and some tests for line
  continuation in comments.
2023-11-03 15:52:02 -05:00
Emanuele Torre 9de0e26ce6 Generate links in man page
Some [foo](bar) links were added to manual.yml without updating
build_manpage.py to make it generate roff for "a" tags.

Fixes #2930
2023-10-12 15:32:23 -05:00
Emanuele Torre 4ebd21e1eb Allow passing the inline jq script before --
jq previously only allowed passing the inline script before -- (as if
they were options) even though one would expect the inline script to be
a positional argument.

Since jq previously also refused to run with a usage error if the script
was passed after -- (It was not assuming  .  as script as it does when
no arguments are passed), and positional arguments are allowed before --
and even before other options, it should not be a breaking change to
change that weird behaviour, and allow the script to appear after --.

It also simplifies the option parsing code a bunch.

Fixes #2918
2023-10-04 00:00:46 -05:00
Thomas Bozeman th026106 7f547827e4 Simplify pick example
Old pick example included input array in command line, making `input` confusing
and redundant.
2023-10-03 22:48:12 +02:00
taoky 8f81668014 Fix the default colors to use 39, the default foreground color (#2904) 2023-09-22 09:18:41 +09:00
Nicolas Williams 583e4a2718 Add --config option printing ./configure options used 2023-08-19 17:40:08 -05:00
itchyny 0733fd3d58 Add a regression test for negative indices and fix a pick/1 test 2023-08-16 17:49:44 -05:00