Skip to content

Instantly share code, notes, and snippets.

@marcinhlybin
Created December 7, 2017 14:05
Show Gist options
  • Save marcinhlybin/b43551baa8da2cd854c58dd707ae4339 to your computer and use it in GitHub Desktop.
Save marcinhlybin/b43551baa8da2cd854c58dd707ae4339 to your computer and use it in GitHub Desktop.
Contemporary Bash Art
while read line; do
if [[ $line =~ ^"["(.+)"]"$ ]]; then
arrname=${BASH_REMATCH[1]}
declare -A $arrname
elif [[ $line =~ ^([_[:alpha:]][_[:alnum:]]*)"="(.*) ]]; then
declare ${arrname}[${BASH_REMATCH[1]}]="${BASH_REMATCH[2]}"
fi
done < /etc/pushover.conf
@marcinhlybin
Copy link
Author

The same in Python:

import configparser
config = configparser.ConfigParser()
config.read('/etc/pushover.conf')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment