I am trying to build a terminal based GUI for a tool. The following code invokes something like this
while true
do
CHOICE=$(dialog --keep-window --clear --no-shadow \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
#*) exec vim "$(echo $CHOICE | cut -d ':' -f 1)" ; ;;
*) filename="$(echo $CHOICE | cut -d ':' -f 1)"
#mkfifo "$TOMATO_DIR/cf"
if [ ! -z $filename ] ; then
dialog --editbox $filename 60 80
#cp "$TOMATO_DIR/cf" $filename
#rm -f ${INPUT}
else
clear
exit 0
fi
clear ;;
esac
done
And on pressing ENTER and editbox as following opens:

I tried opening the file in vim but on saving the file, the tools exits.
I want to know, how to open the file and return to the tool on saving or exiting from vim ?

exec vim ...orvim ...in former case, shell will be replaced by vim, and upon vim exit will dissapear. try using later case.