From c179aa37980ec3c85fa0f7e2cfcde51550669fe6 Mon Sep 17 00:00:00 2001 From: aleskandro Date: Fri, 17 Nov 2023 09:13:43 +0100 Subject: [PATCH] Do not panic when StdIn is closed When the shell executing yq has no open stdin, os.Stdin.Stat() return nil and yq fails to continue. This commit fixes a missing verification on the result of os.Stdin.Stat() in the utils.processStdInArgs function and adds an acceptance test to cover this scenario in the future. This bug affects yq since version 4.26.1. --- acceptance_tests/basic.sh | 8 +++++++- cmd/utils.go | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/acceptance_tests/basic.sh b/acceptance_tests/basic.sh index 01a446e2..c48f7195 100755 --- a/acceptance_tests/basic.sh +++ b/acceptance_tests/basic.sh @@ -362,6 +362,12 @@ EOM assertEquals "$expected" "$X" } - +testBasicClosedStdIn() { + cat >test.yml <