[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] return to menu after stopping an interactive program
From: |
Bruce Hohl |
Subject: |
Re: [Help-bash] return to menu after stopping an interactive program |
Date: |
Fri, 26 Apr 2019 09:00:39 -0400 |
> Don't use exec here if you intend to do anything else.
Disregard the exec. That was just a test I was doing to achieve my desired
end result.
I did not mean to include that in my original posting.
> First of all, no, they are not started as child processes, because you
> used exec. exec means that lynx REPLACES the script.
Again, please disregard the exec (it was just a test).
Without the exec I believe they are child processes.
> Second, don't use Ctrl-Z to suspend a program that you're trying to exit
from.
I DO want to suspend, not exit.
I am looking for away to automatically return to my "infinite loop menu"
after suspending a process.
Basically, I am trying to integrate bash job control features into a menu
script.
On Fri, Apr 26, 2019 at 8:30 AM Greg Wooledge <address@hidden> wrote:
> On Fri, Apr 26, 2019 at 08:21:11AM -0400, Bruce Hohl wrote:
> > read -p "Enter choice " choice
> > echo
> > case $choice in
> > (ls) ls; echo; read -p 'enter for menu';;
> > (lynx) exec lynx;;
> > (top) exec top;;
> > (q|Q) break
> > (*)
> > esac
> > done
> > exit 0
>
> Don't use exec here if you intend to do anything else.
>
> > The programs are started as child processes of the 'menu'
> > script. If lynx is selected/started, then Ctrl-Z is used
> > to stop lynx, it is reported that 'menu' has been stopped:
> > [1]+ Stopped menu
>
> First of all, no, they are not started as child processes, because you
> used exec. exec means that lynx REPLACES the script. There is no more
> script. It's gone.
>
> Second, don't use Ctrl-Z to suspend a program that you're trying to
> exit from. Simply exit from the program normally.
>
> In the case of lynx, you exit by pressing q and then y to confirm. In
> the general case, do whatever the normal way of exiting is for whatever
> program you're in.
>
> > What I really want is to stop the selected item (lynx)
> > and be returned to the (running) menu. Is there a way
> > to do this with interactive programs?
>
> You may want to look at <https://mywiki.wooledge.org/BashFAQ/115>.
>
> Basically, what you want to do is run an infinite loop which prints
> the menu, reads the user's choice, takes some action, and then continues
> the loop, forever. You get back to the menu loop by exiting from
> whatever program the menu launches.
>