]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/bin/sh |
2 | # | |
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: | |
6 | # | |
ee4fdd07 | 7 | # eval $(readhash /var/ipfire/main/settings) |
cd1a2927 MT |
8 | # |
9 | ||
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_]*' | |
13 | ||
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}]*" | |
18 | ||
a393e0ba | 19 | sed -ne "s/\(${VARNAME}\)=\(${VARVAL}\)$/\1=\2/p" $1 |
cd1a2927 MT |
20 | |
21 | # Accept space only if it's quoted | |
a393e0ba | 22 | sed -ne "s/\(${VARNAME}\)=\('[ ${VARCHARS}]*'\)$/\1=\2/p" $1 |