diff --git a/cmd/commands_test.go b/cmd/commands_test.go index f74d677e..872e4a22 100644 --- a/cmd/commands_test.go +++ b/cmd/commands_test.go @@ -1262,7 +1262,7 @@ c: toast: leave test: 1 tell: 1 - taco: cool + tasty.taco: cool ` filename := test.WriteTempYamlFile(content) defer test.RemoveTempYamlFile(filename) @@ -1277,7 +1277,7 @@ c: b: [3, 4] c: toast: leave - taco: cool + tasty.taco: cool ` test.AssertResult(t, expectedOutput, result.Output) } @@ -1443,7 +1443,7 @@ c: test: 1 toast: leave tell: 1 - taco: cool + tasty.taco: cool ` test.AssertResult(t, expectedOutput, result.Output) } @@ -1644,7 +1644,7 @@ c: test: 1 toast: leave tell: 1 - taco: cool + tasty.taco: cool ` test.AssertResult(t, expectedOutput, gotOutput) test.AssertResult(t, os.FileMode(int(0666)), info.Mode()) diff --git a/examples/data2.yaml b/examples/data2.yaml index 07088cc1..9efa4fc6 100644 --- a/examples/data2.yaml +++ b/examples/data2.yaml @@ -4,4 +4,4 @@ c: toast: leave test: 1 tell: 1 - taco: cool + tasty.taco: cool diff --git a/pkg/yqlib/lib.go b/pkg/yqlib/lib.go index 196e3ddf..f4f3889c 100644 --- a/pkg/yqlib/lib.go +++ b/pkg/yqlib/lib.go @@ -51,7 +51,15 @@ func mergePathStackToString(pathStack []interface{}, appendArrays bool) string { } default: - sb.WriteString(fmt.Sprintf("%v", path)) + s := fmt.Sprintf("%v", path) + hasDot := strings.Contains(s, ".") + if hasDot { + sb.WriteString("[") + } + sb.WriteString(s) + if hasDot { + sb.WriteString("]") + } } if index < len(pathStack)-1 {