mrbaseman / parse_yaml

a simple yaml parser implemented in bash
GNU General Public License v3.0
165 stars 37 forks source link

Fail the parsing if the input yaml have syntax error #26

Open vivuu1989 opened 5 months ago

vivuu1989 commented 5 months ago

@mrbaseman Can we have a feature or way to fail the script parsing if the input file parsing didt work or yaml file input has wrong syntax.

mrbaseman commented 5 months ago

That's really difficult, because the script rarely uses loops. Mostly, it just uses pattern matching of sed, and my feeling is that this gets stuck under some conditions, that are at least not obvious. My naive understanding would have been, that it just matches some part of the file and assigns it to a variable or ignores it completely, and continues with the rest of the file. As I have mentioned in #23, my observation in the past was, that it sometimes gets stuck, and usually appending an empty line to the input file just resolves this, but you haven't given any feedback if that approach has helped in your case, too. At least for the dev-policy.yaml file from #23 it helps on my Ubuntu installation. I have just pushed commit 3752ef9 which does this, in the hope, that it addresses the issue in general. If you observe similar symptoms that are not solved by this commit, please post a yaml file to reproduce the problem.