yq
yq copied to clipboard
Allow shebang on the first line of a file of `yq` filters
Please describe your feature request.
To enable the creation of .yq
executable files, I would like yq
to allow the first line of a --from-file
to be a "shebang" (#!
) which is subsequently ignored in the interpretation of the file contents.
Describe the solution you'd like If we have data1.yml like:
country:
Australia:
- city: Perth
and data2.yml like:
country:
Australia:
- city: Brisbane
and merge-aus.yq like:
#!/usr/bin/env yq --null-input --from-file
load("data1.yml") as $perth |
load("data2.yml") as $bris |
$perth *+ $bris
And we run a command:
./merge-aus.yq
it could output
country:
Australia:
- city: Perth
- city: Brisbane
Describe alternatives you've considered
I usually just write a shell script wrapper called merge-aus.yq
which calls the appropriate yq --from-file
command, but first class support would be awesome.
I have cloned the source locally, and will fork to create a PR if I can get to it :)
That would be very cool - would love a PR
Had a look at your draft PR @rlee-arx and worked out how to do it 👍🏼 . Will be in the next release.
Fixed in 4.42.1
Please describe your feature request. To enable the creation of
.yq
executable files, I would likeyq
to allow the first line of a--from-file
to be a "shebang" (#!
) which is subsequently ignored in the interpretation of the file contents.Describe the solution you'd like If we have data1.yml like:
country: Australia: - city: Perth
and data2.yml like:
country: Australia: - city: Brisbane
and merge-aus.yq like:
#!/usr/bin/env yq --null-input --from-file load("data1.yml") as $perth | load("data2.yml") as $bris | $perth *+ $bris
And we run a command:
./merge-aus.yq
it could output
country: Australia: - city: Perth - city: Brisbane
Describe alternatives you've considered I usually just write a shell script wrapper called
merge-aus.yq
which calls the appropriateyq --from-file
command, but first class support would be awesome.I have cloned the source locally, and will fork to create a PR if I can get to it :)
<chatgpt_3.5_turbo><help_block_devices_/> ``
Allow shebang on the first line of a file of yq filters https://github.com/mikefarah/yq/issues/1851#bl9ck