-
-
Notifications
You must be signed in to change notification settings - Fork 600
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
Wrong assumption about missing '-' arg if pipingStdin
detected
#1115
Comments
Yeah I can replicate that - but not actually sure how to fix it. Any golang experts? I'm doing this to detect if there's stdin: stat, _ := os.Stdin.Stat()
pipingStdIn := (stat.Mode() & os.ModeCharDevice) == 0 which from what I read is the correct way, but yes it appears to be too eager :/ |
Maybe adding |
...that's a great idea!
…________________________________
From: Aleksandr Vinokurov ***@***.***>
Sent: Thursday, February 17, 2022 5:51:07 PM
To: mikefarah/yq ***@***.***>
Cc: Mike Farah ***@***.***>; Comment ***@***.***>
Subject: Re: [mikefarah/yq] Wrong assumption about missing '-' arg if `pipingStdin` detected (Issue #1115)
Maybe adding - only if no files are on the args list?
—
Reply to this email directly, view it on GitHub<#1115 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAIZHNK4RMKXOJMSRLSEST3U3SLFXANCNFSM5OS75OQA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID: ***@***.***>
|
mikefarah
added a commit
that referenced
this issue
Feb 20, 2022
Fixed in 4.20.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When
yq
is placed inside a bigger block where other commands read from stdin which is piped to that whole block,yq
is egoistically reading the stdin.The commit 703418d adds "-" to the args when
pipingStdin
is detected.Version of yq: 4.20.1
Operating system: mac
Installed via: homebrew
Command
Problem appears when used in blocks, so the minimal script that reproduces the problem:
Actual behavior
The
read
of thewhile
block is intended to read1
and2
on each iteration ofwhile
but in practice there is nothing left forread
afteryq
finished his one call, and2
can be found infoo-1.yaml
:Expected behavior
Workaround
In such cases when
yq
is involved in a block of commands which has its stdin piped (but not foryq
) the egoism ofyq
can be fed with</dev/null
. So the line in the before mentioned script would be:The text was updated successfully, but these errors were encountered: