Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify -f argument parsing #3199

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading