mattolenik / hclq

Command-line processor for HashiCorp config files, like sed for HCL — Terraform, Consul, Nomad, Vault
https://hclq.sh
The Unlicense
254 stars 23 forks source link

[Bug] missing quote in get with raw flag #21

Open caongocthai opened 4 years ago

caongocthai commented 4 years ago

Create simple hcl file example.tf:

data "foo" {
  "bar" = "        - \"one\"\n        - \"-two\"\n        - \"three\""
}

Run: cat example.tf | hclq get --raw 'data.foo.bar'

Expect:

        - "one"
        - "-two"
        - "three"

Get:

        - "one"
        - "-two"
        - "three    <- missing the last double quote here 

This 2 scenarios would work fine without problem:

data "foo" {
  "bar" = "        - \"one\"\n        - \"-two\"\n        - \"three\"\n"  <- add a new line \n at the end here
}

or

data "foo" {
  "bar" = "        - 'one'\n        - '-two'\n        - 'three'"  <- use single quote ' instead of escape double quotes \"
}