Skip to content

Allow passing additional arguments through to --jq script, just like we can with jq --arg #10263

@0xdevalias

Description

@0xdevalias

Describe the feature or problem you’d like to solve

There are times where it would be useful to be able to pass through arbitrary arguments to a --jq script without needing to result to hacks such as using shell variables/etc to unsafely inject content into the script.

⇒ jq -h

..snip..
      --arg name value      set $name to the string value;
      --argjson name value  set $name to the JSON value;
      --slurpfile name file set $name to an array of JSON values read
                            from the file;
      --rawfile name file   set $name to string contents of file;
      --args                consume remaining arguments as positional
                            string values;
      --jsonargs            consume remaining arguments as positional
                            JSON values;
..snip..

This would allow us to do things like pass through a user choice from the CLI args to a script that supports multiple options (eg. this script could support both grouped and ungrouped without resorting to "please uncomment the block you want: #659 (comment))

Proposed solution

Allowing more flexibility to safely pass arguments into the --jq scripts without resorting to hacks such as unsafely injecting shell variables into the script (and then needing to manually escape everything else the shell might interpret within the script)

Additional context

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions