Created
January 20, 2015 14:26
-
-
Save drscream/0db2bb944e23232f9114 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
configfile='/tmp/myconfig.cfg' | |
configfile_secured='/tmp/myconfig_secured.cfg' | |
# check if the file contains something we don't want | |
if egrep -q -v '^#|^[^ ]*=[^;]*' "$configfile"; then | |
echo "Config file is unclean, cleaning it..." >&2 | |
# filter the original to a new file | |
egrep '^#|^[^ ]*=[^;&]*' "$configfile" > "$configfile_secured" | |
configfile="$configfile_secured" | |
fi | |
# now source it, either the original or the filtered variant | |
source "$configfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment