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

indices behaves differently when dealing with arrays vs strings #3030

Closed
kklingenberg opened this issue Feb 4, 2024 · 2 comments
Closed

Comments

@kklingenberg
Copy link

Describe the bug

Not sure if it is a bug. The behaviour of indices differs when given arrays vs strings when the matches overlap.

To Reproduce

[0, 0, 0] | indices([0, 0]) == [0, 1]

vs.

"aaa" | indices("aa") == [0]

Expected behavior

Both cases should match, or if the difference is intented the string case should be documented.

Environment (please complete the following information):

  • OS and Version: Ubuntu 22.04
  • jq version 1.7

Additional context

Related issue in jaq: 01mf02/jaq#154

@itchyny
Copy link
Contributor

itchyny commented Feb 4, 2024

Previously jq 1.6 worked like this but I think jq 1.7 works as expected (fixed by #2718).

@kklingenberg
Copy link
Author

You're right, I accidentally used the previous version of jq when running the example :(

Sorry.

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

No branches or pull requests

2 participants