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
yaml2sh myfile
yaml2sh myfile > somefile
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.
key: value
key="value"
Inline lists are supported and will be outputted as a simple shell array.
key: [value1, value2, value3]
key=( "value1" "value2" "value3" )