0k / shyaml

YAML for command line
BSD 2-Clause "Simplified" License
767 stars 57 forks source link

Inconsistency with ``get-value`` outputing either YAML or literal string #33

Closed vaab closed 6 years ago

vaab commented 7 years ago

Most of the time, the output from get-value can be re-used as YAML and piped again into shyaml. For anything else than str type, this is consistent. But it is not for str:

cat <<EOF > test.yml
a: |
    this is a string with a semicolon: it should remain
    a string with semicolon.
EOF

I'm expecting that:

cat test.yml | shyaml get-type a

and

cat test.yml | shyaml get-value a |  shyaml get-type

give the same value.

The second crashes.

So it seems that we need a shyaml get-value that outputs YAML quoted strings. This problem comes from the dump function used in shyaml get-value and all over the place. This function is indeed breaking YAML compatibility clearly, by refusing yaml.dump to print the correct value.

Of course, backwards compatibility is important, so we can't just change the behavior of get-value, but we might want to add for instance a -y or --yaml when we are sure we want YAML only.

vaab commented 6 years ago

This was fixed a long time ago in 3d237e8 for version 5.0.