One-shot parsing.
This commit is contained in:
parent
8d903860c4
commit
ab0e7c77d9
1 changed files with 13 additions and 20 deletions
33
fetch_fio.sh
33
fetch_fio.sh
|
@ -61,26 +61,19 @@ while ! [ -z "$1" ] ; do
|
|||
done
|
||||
|
||||
# Configuration parsing
|
||||
cat "$CONFIG_FILE" \
|
||||
| sed 's/#.*//' \
|
||||
| while read line ; do
|
||||
name=${line%% *}
|
||||
value=${line#* }
|
||||
echo ===
|
||||
echo $line
|
||||
echo $name
|
||||
echo $value
|
||||
case "$name" in
|
||||
apikeys-file)
|
||||
echo "APIKEYS"
|
||||
CFG_APIKEYS_FILE="$value"
|
||||
;;
|
||||
bank-dir)
|
||||
echo "BANK_DIR"
|
||||
CFG_BANK_DIR="$value"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
get_config_value() {
|
||||
if [ -z "$1" ] ; then
|
||||
echo "get_config_value() requires parameter name"
|
||||
exit 1
|
||||
fi
|
||||
cat "$CONFIG_FILE" \
|
||||
| sed 's/#.*//' \
|
||||
| sed 's/^[ \t]*//' \
|
||||
| grep "^$1" \
|
||||
| sed 's/^[^ \t]*//'
|
||||
}
|
||||
CFG_BANK_DIR=`get_config_value bank-dir`
|
||||
CFG_APIKEYS_FILE=`get_config_value apikeys-file`
|
||||
|
||||
# Configuration merging
|
||||
if [ -z "$ARG_BANK_DIR" ] ; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue