-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.sh
53 lines (43 loc) · 1000 Bytes
/
sample.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# ##############################################################################
#
# @description "sample"
# @name sample.sh
# @author T.Hayashi@Rookie Inc
# @version 1.0 2023/10/04
# Copyright(c) 2023 Toshinoli-Hayashi
#
# ##############################################################################
#
# _DEBUG_=1
#
[ ${_DEBUG_} ] && echo "DEBUG MSG: ON" >&2
# Required var
_J2SVDIR=$(dirname $0)
_J2SVLIB="${_J2SVDIR}/lib"
# chk param
if [ -z "${1}" ]; then
echo >&2 "Error: sample: require conf json file name"
return 1
fi
if [ -z "${2}" ]; then
echo >&2 "Error: sample: require tag name"
return 1
fi
if [ -z "${3}" ]; then
echo >&2 "Error: sample: require key name"
return 1
fi
# set var
_jsonfile=${1}
_tag=${2}
_key=${3}
# include lib
_FNCFILE="${_J2SVDIR}/json2shvars.lib.sh"
. ${_FNCFILE}
# make configuration, load and delete
_conf=$(mkConf ${_jsonfile} ${_tag})
. ${_conf}
rm ${_conf}
_var=$(eval "echo \"\${${_key}}\"")
echo "${_tag} var ${_key} ${_var}"