Skip to content

Add shell macro support #2336

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

Open
ponchofiesta opened this issue Apr 2, 2025 · 1 comment
Open

Add shell macro support #2336

ponchofiesta opened this issue Apr 2, 2025 · 1 comment

Comments

@ponchofiesta
Copy link

Please describe your feature request.
yq should support sh macros to allow any custom string manipulation.

Describe the solution you'd like

Example:

There is a secrets file like this:

a:
  token: "abcdef"
b:
  token: "xyz"

I want to get some hashes of these secrets:

yq -o=tsv '.. | { "k": path | join("."), "v": .token | @sh "echo -n ${1} | sha256sum | cut -d\' \' -f1" } | .k + ": " + .v' secrets.yml

This should print something like:

a: ae0666f161fed1a5dde998bbd0e140550d2da0db27db1d0e31e370f2bd366a57
b: f34fe622a8fe7565fc15be3ce8bc43d7e32a0dd744ebef509fa0bdb130c0ac31

Describe alternatives you've considered
Using shell with multiple lines of code

Additional context

@ponchofiesta
Copy link
Author

Similar by the chosen example but not exactly the same: #2283

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

1 participant