load configuration from array and optional file
This commit is contained in:
parent
a801fef36d
commit
9c8479bf45
10
ysm.sh
10
ysm.sh
|
@ -12,6 +12,7 @@ default_action="increment"
|
|||
default_path="$HOME/.ysess"
|
||||
default_s_path="$HOME/.ysess/*.ysess"
|
||||
|
||||
declare -A config
|
||||
config=(
|
||||
[extension]="ysess"
|
||||
[name]="last.$extension"
|
||||
|
@ -21,6 +22,15 @@ config=(
|
|||
[s_path]="$HOME/.ysess/*.ysess"
|
||||
)
|
||||
|
||||
while read line
|
||||
do
|
||||
if echo $line | grep -F = &>/dev/null
|
||||
then
|
||||
varname=$(echo "$line" | cut -d '=' -f 1)
|
||||
config[$varname]=$(echo "$line" | cut -d '=' -f 2-)
|
||||
fi
|
||||
done < ${config[path]}/ysm.conf
|
||||
|
||||
CreateFiles() {
|
||||
if [ ! -d "$default_path" ]; then
|
||||
mkdir $HOME/.ysess
|
||||
|
|
Loading…
Reference in New Issue