bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interactive job control and looping constructs


From: Chet Ramey
Subject: Re: Interactive job control and looping constructs
Date: Wed, 24 Dec 2014 15:11:25 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 12/24/14 6:51 AM, Ed Avis wrote:
> At an interactive bash prompt, run a 'for' loop:
> 
> % for i in a b c; do echo $i; sleep 10; done
> 
> Then interrupt this with Ctrl-Z.  The process interrupted is just whichever
> sleep process was running at the time.  You can then resume it with 'fg' but
> the loop does not continue.
> 
> I understand that job control applies to processes and that bash does not
> create a new process to run a 'for' loop.  You can force it to do so:
> 
> % (for i in a b c; do echo $i; sleep 10; done)
> 
> Now job control does something more sensible; the whole loop can be paused,
> put into the background or the foreground.  But if you didn't have the
> foresight to put () around your command, you are stuck if you later decide
> you want to put it in the background.
> 
> Is there something bash could do to be more user-friendly here?

Such a feature has been in the wish list category for a while, but it has
not risen high enough on the priority list for me to tackle an
implementation.  I would be happy to look at a code contribution to
implement it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]