-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Allow shebang on the first line of a file of yq
filters
#1851
Comments
That would be very cool - would love a PR |
Fairly dirty way of allowing shebang lines This snippet will read the first two characters of a file passed in to `yq` and remove the line if it begins with "`#!`". This will allow `yq` to continue parsing it as though the shebang line was not there. I was not able to find canonical documentation that the shebang is limited to a single line or cannot include continuation characters. However these seem to be accepted truths. See: https://linux.die.net/man/2/execve https://en.wikipedia.org/wiki/Shebang_(Unix)#Syntax
Fairly dirty way of allowing shebang lines This snippet will read the first two characters of a file passed in to `yq` and remove the line if it begins with "`#!`". This will allow `yq` to continue parsing it as though the shebang line was not there. I was not able to find canonical documentation that the shebang is limited to a single line or cannot include continuation characters. However these seem to be accepted truths. See: https://linux.die.net/man/2/execve https://en.wikipedia.org/wiki/Shebang_(Unix)#Syntax
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 |
<chatgpt_3.5_turbo><help_block_devices_/> |
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 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:
and data2.yml like:
and merge-aus.yq like:
And we run a command:
it could output
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 :)
The text was updated successfully, but these errors were encountered: