Fixed bug - ignore path expressions that match a directory

This commit is contained in:
Mike Farah 2022-02-07 08:04:26 +11:00
parent 926a68181b
commit 5ac3c57510
2 changed files with 8 additions and 2 deletions

View File

@ -10,6 +10,12 @@ testBasicEvalRoundTrip() {
assertEquals 123 "$X" assertEquals 123 "$X"
} }
testBasicPipeWithDot() {
./yq -n ".a = 123" > test.yml
X=$(cat test.yml | ./yq '.')
assertEquals 123 "$X"
}
testBasicEvalRoundTripNoEval() { testBasicEvalRoundTripNoEval() {
./yq -n ".a = 123" > test.yml ./yq -n ".a = 123" > test.yml
X=$(./yq '.a' test.yml) X=$(./yq '.a' test.yml)

View File

@ -98,6 +98,6 @@ func configureEncoder(format yqlib.PrinterOutputFormat) yqlib.Encoder {
// without this - yq detects there is stdin (thanks githubactions), // without this - yq detects there is stdin (thanks githubactions),
// then tries to parse the filename as an expression // then tries to parse the filename as an expression
func maybeFile(str string) bool { func maybeFile(str string) bool {
_, err := os.Stat(str) // #nosec stat, err := os.Stat(str) // #nosec
return err == nil return err == nil && !stat.IsDir()
} }