I like to �optimize� / make more like a real program my bash script by replacing repetitious code which utilizes positional parameters.
I am having two issues I cannot solve and would appreciate some assistance with resolving them.
a) how to modify the whiptail checklist �menu� and insert it into whiptail
b) how to replace each case with common code checking only even positional parameters
Each and every choice selected is plain command hence a common function.
I did try the while / do done but it did not echo positional parameters
whiptail_DEBUG_BASE_arg(){
# BUG did not print positional parameters
x=1
while [ $x -le 5 ]
do
echo "Welcome {${x}} times"
x=$(( $x + 1 ))
done
pause
whiptail --title "$1" \
--checklist \
--separate-output "Choose:" 20 78 15 \
"$2" "$3" on \
"$4" "$5" off \
"$6" "$7" off \
"$8" "$9" off \
"${10}" "${11}" off \
"${12}" "${13}" off \
"${14}" "${15}" off \
"${16}" "${17}" off \
"${18}" "${19}" off \
"${20}" "${21}" off \
"${22}" "${23}" off \
"${24}" "${25}" off \
"${10}" "${11}" off \
"${12}" "${13}" off \
"${14}" "${15}" off \
"${16}" "${17}" off \
"${18}" "${19}" off \
"${20}" "${21}" off \
"${22}" "${23}" off \
"${24}" "${25}" off \
2>results
while read choice
do
case $choice in
$2)
$2 # execute command
;;
$4)
$4
;;
$6)
$6
;;
$8)
$8
;;
${10})
${10}
;;
${12})
${12}
;;
${14})
${14}
;;
*) echo "Invalid entry!"
;;
# BUG echo "$choice"
esac
done < results
pause
p { margin-bottom: 0.1in; line-height: 115%; }