Toml v0.4.0 parser written in pure Bash
STATUS: EXPERIMENTAL
declare -A TOML=() source bash-toml <<-"EOF" five = 'value' EOF printf '%s' "${TOML[five]}" # value- Bail Fast
This means error handling is performed by bash-toml. More specifically, if there is a problem parsing, the script will exit. This is useful if you want to use bash-toml for a quick thing, and want to bail fast, irrespective of the errexit option. Of course, if you execute this in a subshell (potentially depending on the pipefail option), the main shell won't exit at all
# file.sh set +e source ./bash-toml.sh bash-toml <<< "key = '"$ ./file.sh # => exitCode 1 Error: Could not finish single quote string, etc.- Control
If you want to have more fine-grained control over your error handling
# file.sh set +e source ./bash-toml.sh TOML_MANUAL_ERROR='yes' if ! bash-toml <<< "key = '"; then if [ -n "$TOML_ERROR" ]; then # Problem with the 'file.toml' : else # Internal 'bash-toml' error exit 2 fi fi$ ./file.sh # => exitCode 0