Skip to content

Commit

Permalink
Clarify -f argument parsing (#3199)
Browse files Browse the repository at this point in the history
  • Loading branch information
thaliaarchi authored Nov 9, 2024
1 parent eb9bdca commit 32a304b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions docs/content/manual/dev/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ sections:
RS. This mode also parses the output of jq without the `--seq`
option.
* `-f filename` / `--from-file filename`:
* `-f` / `--from-file`:
Read filter from the file rather than from a command line, like
awk's -f option.
Read the filter from a file rather than from a command line,
like awk's -f option. This changes the filter argument to be
interpreted as a filename, instead of the source of a program.
* `-L directory` / `--library-path directory`:
Expand Down Expand Up @@ -3633,7 +3634,7 @@ sections:
# total - Output the sum of the given arguments (or stdin)
# usage: total [numbers...]
# \
exec jq --args -MRnf "$0" -- "$@"
exec jq --args -MRnf -- "$0" "$@"
$ARGS.positional |
reduce (
Expand All @@ -3653,7 +3654,7 @@ sections:
end of the line does not continue the comment.
With this trick, when the script is invoked as `total 1 2`,
`/bin/sh -- /path/to/total 1 2` will be run, and `sh` will then
run `exec jq --args -MRnf /path/to/total -- 1 2` replacing itself
run `exec jq --args -MRnf -- /path/to/total 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`.
Expand Down
8 changes: 4 additions & 4 deletions jq.1.prebuilt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void usage(int code, int keep_it_short) {
" --stream-errors implies --stream and report parse error as\n"
" an array;\n"
" --seq parse input/output as application/json-seq;\n"
" -f, --from-file file load filter from the file;\n"
" -f, --from-file load the filter from a file;\n"
" -L, --library-path dir search modules from the directory;\n"
" --arg name value set $name to the string value;\n"
" --argjson name value set $name to the JSON value;\n"
Expand Down

0 comments on commit 32a304b

Please sign in to comment.