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

main.c: remove a FIXME #3095

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

main.c: remove a FIXME #3095

wants to merge 1 commit into from

Conversation

emanuele6
Copy link
Member

Using an "invalid" variable name is fine, it just means you will only be
able to access that argument from $ARGS.named

Using an "invalid" variable name is fine, it just means you will only be
able to access that argument from $ARGS.named
@wader
Copy link
Member

wader commented Apr 18, 2024

Huh didn't know. Help says --arg name value set $name to the string value; so maybe we should check?

@emanuele6
Copy link
Member Author

emanuele6 commented Apr 18, 2024

I don't see the point in restring that; jq -n ... '$ARGS.named' is a fairly common pattern to construct objects from some shell variables; e.g.

jq -n \
    --arg foo "$(something "$baz")" \
    --arg bar "$thisthing" \
    '$ARGS.named'

We would be preventing users from constructing objects with this-cool-key using this method; it is likely that there are scripts that already rely on this.

Maybe the --help description could be extended? (Wouldn't that take too much space?)

The man page entry for --arg (but only the one for --arg even though it also works with --argjson, --slurpfile, etc) mentions that the arguments are also available in the $ARGS.named object, but does not say anything about $name only being assigned if name is a valid identifer

--arg name value:

    This option passes a value to the jq program as a predefined
    variable. If you run jq with --arg foo bar, then $foo is available
    in the program and has the value "bar". Note that value will be
    treated as a string, so --arg foo 123 will bind $foo to "123".

    Named arguments are also available to the jq program as
    $ARGS.named.

@emanuele6 emanuele6 added the docs label Apr 18, 2024
@emanuele6 emanuele6 marked this pull request as draft April 18, 2024 13:37
@wader
Copy link
Member

wader commented Apr 18, 2024

Good points, yeap maybe enough to add some note about it in the more detailed arg docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants