Skip to content

Confusing error caused by bash-like pattern *"pattern"* #2484

@NickVeld

Description

@NickVeld

Describe the bug

The error with the pattern produces confusing error for other operator. I wrote a pattern in bash-style ( *"pattern"* ) instead of right ( "*pattern*"). I got Error: '|' expects 2 args but there is 1. My command was long with several | so it took some time to find the error. Since Bash is popular I do not think I am the only one who can do the same mistake.

Version of yq: 4.44.6
Operating system: linux
Installed via: binary release/

Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)

-

Command
The command you ran:

yq --null-input 'select(. == *""*)'
yq --null-input '... | select(. == *""*)'
yq --null-input '.a = 5 | ... | select(. == *""*)'

Actual behavior

Error: '*' expects 2 args but there is 1
Error: '==' expects 2 args but there is 1
Error: '|' expects 2 args but there is 1

Expected behavior

Something like:

Error: '*' is not valid in this context
Error: '*' is not valid in this context
Error: '*' is not valid in this context

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions