]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/scripts/readhash
3 # This script reads in variables from a config file, and produces a list of
4 # commands to run to set these as shell environment variables, it is
5 # intended to be used as follows:
7 # eval $(readhash /var/ipfire/main/settings)
10 # shell variables must consist of alphanumeric characters and underscores,
11 # and begin with an alphabetic character or underscore.
12 VARNAME
='[A-Za-z_][A-Za-z0-9_]*'
14 # For the assigned value we only accept a limited number of characters - none
15 # of which are shell metachars
16 VARCHARS
='A-Za-z0-9=/,.:%_@#+-'
17 VARVAL
="[${VARCHARS}]*"
19 sed -ne "s/\(${VARNAME}\)=\(${VARVAL}\)$/\1=\2/p" $1
21 # Accept space only if it's quoted
22 sed -ne "s/\(${VARNAME}\)=\('[ ${VARCHARS}]*'\)$/\1=\2/p" $1