enclose configuration in function

This commit is contained in:
Joe 2020-02-16 07:25:42 -06:00
parent 4c10896d12
commit 7315442b1f
Signed by: joe
GPG Key ID: 8595A3F8F2CE1B74
1 changed files with 19 additions and 17 deletions

36
ysm.sh
View File

@ -5,24 +5,26 @@ version=0.1.0
author="Joe <joe@thisisjoes.site>" author="Joe <joe@thisisjoes.site>"
license="GNU GPLv3" license="GNU GPLv3"
declare -A config Configure() {
config=( declare -A config
[extension]="ysess" config=(
[name]="last.$extension" [extension]="ysess"
[format]="+%d%m%Y_%H%M%S" [name]="last.$extension"
[action]="increment" [format]="+%d%m%Y_%H%M%S"
[path]="$HOME/.ysess" [action]="increment"
[s_path]="$HOME/.ysess/*.ysess" [path]="$HOME/.ysess"
) [s_path]="$HOME/.ysess/*.ysess"
)
while read line while read line
do do
if echo $line | grep -F = &>/dev/null if echo $line | grep -F = &>/dev/null
then then
varname=$(echo "$line" | cut -d '=' -f 1) varname=$(echo "$line" | cut -d '=' -f 1)
config[$varname]=$(echo "$line" | cut -d '=' -f 2-) config[$varname]=$(echo "$line" | cut -d '=' -f 2-)
fi fi
done < ${config[path]}/ysm.conf done < ${config[path]}/ysm.conf
}
CreateFiles() { CreateFiles() {
if [ ! -d ${config[path]} ]; then if [ ! -d ${config[path]} ]; then