From 5ac3c5751057d3b0d9ed5c06ba3f372c5ce5c347 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 7 Feb 2022 08:04:26 +1100 Subject: [PATCH] Fixed bug - ignore path expressions that match a directory --- acceptance_tests/basic.sh | 6 ++++++ cmd/utils.go | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/acceptance_tests/basic.sh b/acceptance_tests/basic.sh index 5bdccbbf..2d0c0f9b 100755 --- a/acceptance_tests/basic.sh +++ b/acceptance_tests/basic.sh @@ -10,6 +10,12 @@ testBasicEvalRoundTrip() { assertEquals 123 "$X" } +testBasicPipeWithDot() { + ./yq -n ".a = 123" > test.yml + X=$(cat test.yml | ./yq '.') + assertEquals 123 "$X" +} + testBasicEvalRoundTripNoEval() { ./yq -n ".a = 123" > test.yml X=$(./yq '.a' test.yml) diff --git a/cmd/utils.go b/cmd/utils.go index 48d1aec9..8908bcbc 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -98,6 +98,6 @@ func configureEncoder(format yqlib.PrinterOutputFormat) yqlib.Encoder { // without this - yq detects there is stdin (thanks githubactions), // then tries to parse the filename as an expression func maybeFile(str string) bool { - _, err := os.Stat(str) // #nosec - return err == nil + stat, err := os.Stat(str) // #nosec + return err == nil && !stat.IsDir() }