enclose configuration in function

dev
Joe 3 years ago
parent 4c10896d12
commit 7315442b1f
Signed by: joe
GPG Key ID: 8595A3F8F2CE1B74
  1. 36
      ysm.sh

@ -5,24 +5,26 @@ version=0.1.0
author="Joe <joe@thisisjoes.site>"
license="GNU GPLv3"
declare -A config
config=(
[extension]="ysess"
[name]="last.$extension"
[format]="+%d%m%Y_%H%M%S"
[action]="increment"
[path]="$HOME/.ysess"
[s_path]="$HOME/.ysess/*.ysess"
)
Configure() {
declare -A config
config=(
[extension]="ysess"
[name]="last.$extension"
[format]="+%d%m%Y_%H%M%S"
[action]="increment"
[path]="$HOME/.ysess"
[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
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 ${config[path]} ]; then

Loading…
Cancel
Save