yaml2sh: Parses simple yaml into shell format
I found myself having the need for declaring simple properties files quite often and while writing simple shell variables into a file and sourcing that often works well, it's not always as readable as I'd wish. Because of this, I wrote an awk script that will read a specified file and output a format suitable for shell consumption.
- Download yaml2sh
- Make it executable: chmod +x yaml2sh
Parsing a file to stdout
Parsing a file, storing the result in another file
yaml2sh myfile > somefile
Parsing a file and sourcing the result to shell variables
source `yaml2sh myfile`
The yaml2sh script can't parse any YAML, it only supports a subset. This may change in the future.
Simple key value pairs will be turned into simple variables, where the key is variable name (verbatim) and the value is, well, the value.
Inline lists are supported and will be outputted as a simple shell array.
key: [value1, value2, value3]
key=( "value1" "value2" "value3" )