enclose configuration in function
This commit is contained in:
parent
4c10896d12
commit
7315442b1f
36
ysm.sh
36
ysm.sh
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue