0

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

enter image description here

And on pressing ENTER and editbox as following opens: enter image description here

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 ?

2
  • 1
    did you use exec vim ... or vim ... in former case, shell will be replaced by vim, and upon vim exit will dissapear. try using later case. Commented Sep 28, 2016 at 11:21
  • @Archemar That worked perfectly !! Can you please explain why this happens ? Commented Sep 28, 2016 at 11:41

1 Answer 1

0

exec is a shell builtin as per bash man page (be patient, it is far away)

   exec [-cl] [-a name] [command [arguments]]
          If command is specified, it replaces the shell.  No new process is created.

consider 2 script

exec ls
pwd

and

ls
pwd

if you execute the first shell, exec ls command will replace shell (discarding remaining input), pwd command will never get exectued.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.