Skip to content

Instantly share code, notes, and snippets.

@toddlers
Created May 28, 2013 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddlers/5661057 to your computer and use it in GitHub Desktop.
Save toddlers/5661057 to your computer and use it in GitHub Desktop.
Simple YAML fine validation for syntax
#! /bin/bash
file=$1
set -a
if [ -z "$file" ]; then
echo "need YAML file as first arg"
exit 2
fi
if [ -f $file ]; then
YAML_FILE=$file
perl -MData::Dumper -MYAML -e '$h = YAML::LoadFile($ENV{YAML_FILE}); print Dumper $h' && echo OK || echo Failed
else
echo $file: no such file or directory
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment