securisation de la commande say

This commit is contained in:
jhechavarria
2018-08-23 02:51:06 +02:00
parent 021988fe88
commit a4a810634f

18
say.sh
View File

@@ -132,14 +132,14 @@ say ()
cfg=`cat $CFGPATH`; cfg=`cat $CFGPATH`;
IFS=', ' read -r -a cfg <<< "$cfg"; IFS=', ' read -r -a cfg <<< "$cfg";
text=( "$@" ); text=( "$@" );
if [ $# -ge 2 -a -f $2 ]; then if [ $# -ge 2 ]; then
unset text[1]; if [ -f $2 ]; then
tmp=`cat $2`; unset text[1];
text=( "${text[@]}" "${tmp[@]}" ); tmp=`cat $2`;
text=( "${text[@]}" "${tmp[@]}" );
fi
fi fi
if [ -t 0 ]; then if [ ! -t 0 ]; then
echo "Interactive Mode";
else
while read -a line; do while read -a line; do
text=( "${text[@]}" "${line[@]}" ); text=( "${text[@]}" "${line[@]}" );
done done
@@ -149,6 +149,10 @@ say ()
cfg[0]=$1; cfg[0]=$1;
unset text[0]; unset text[0];
fi fi
if [ `echo "${text[*]}" | wc -c` -eq 1 ]; then
echo "Give me something to say!"
return
fi
pico2wave -l ${cfg[0]} -w $SNDPATH "${text[*]}"; pico2wave -l ${cfg[0]} -w $SNDPATH "${text[*]}";
play $SNDPATH vol ${cfg[1]} speed ${cfg[2]}; play $SNDPATH vol ${cfg[1]} speed ${cfg[2]};
} }