myvesta/func/handle_parameters.sh
2022-03-24 18:20:31 +01:00

20 lines
440 B
Bash

# handle --parameters=val
handle_parameter() {
origparam=$1
searchstring="="
paramminuses=${origparam:0:2}
if [ "$paramminuses" = "--" ]; then
var_without_minuses=${origparam:2}
var=${var_without_minuses%%=*}
val=${origparam#*$searchstring}
# echo "$var = $val"
printf -v "$var" '%s' "$val"
fi
}
numargs=$#
for ((i=1 ; i <= numargs ; i++))
do
handle_parameter ${@:$i:1}
done