simplification de la fonction saycfg

This commit is contained in:
jhechavarria
2018-08-23 06:32:39 +02:00
parent 320173fee7
commit e0f5790974

29
say.sh
View File

@@ -38,34 +38,15 @@ saysupport()
saycfg ()
{
cfg=`cat $CFGPATH`;
IFS=', ' read -r -a cfg <<< "$cfg";
if [ $# -ge 1 ]; then
saysupport $1;
if [ $? -eq 1 ]; then
cfg[0]="$1";
fi
fi
if [ $# -ge 2 ]; then
re='^[0-2](\.[0-9])?$'
if [[ $2 =~ $re ]]; then
num=`echo "0 + $2" | bc`;
if [ `echo "$num >= 0 && $num <= 2" | bc` -eq 1 ]; then
cfg[1]="$num";
saylng $1
if [ $# -ge 2 ]; then
sayvol $2
if [ $# -ge 3 ]; then
sayspd $3
fi
fi
fi
if [ $# -ge 3 ]; then
re='^[0-2](\.[0-9])?$'
if [[ $2 =~ $re ]]; then
num=`echo "0 + $3" | bc`;
if [ `echo "$num >= 0.5 && $num <= 1.5" | bc` -eq 1 ]; then
cfg[2]="$num";
fi
fi
fi
if [ $# -ge 1 ]; then
echo "${cfg[*]}" > $CFGPATH;
fi
echo "${cfg[*]}";
}