Add bashparam
This commit is contained in:
22
bashparam
Normal file
22
bashparam
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
declare -A __params
|
||||
|
||||
function has_param {
|
||||
[[ -z ${__params[$1]} ]]
|
||||
}
|
||||
|
||||
function get_param {
|
||||
echo "${__params[$1]}"
|
||||
}
|
||||
|
||||
# set_param <longname> <value>
|
||||
function set_param {
|
||||
if [[ -z $2 ]]; then
|
||||
>&2 echo "${FUNCNAME}: non-zero value expected"
|
||||
return 1
|
||||
fi
|
||||
$__params[${1:2}]=${2}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user