On 9/21/18 7:49 AM, esori...@gsyc.urjc.es wrote:
> According to the manual:
> 
> (I)  Typing the suspend character (typically ^Z, Control-Z) 
>      while a process is running causes that process to be
>      stopped and returns control to bash.
> 
> (II) An OR list has the form
> 
>               command1 || command2
> 
>      command2  is executed if and only if command1
>      returns a non-zero exit status.  The return status of
>      AND and OR lists is the exit status of the last 
>      command executed in the list.
> 
> In the following example:
> 
> esoriano@omac:~$ sleep 10 || echo hey
> ^Z
> [5]+  Stopped                 sleep 10
> hey
> esoriano@omac:~$ 
> 
> there are two different issues:
> 
> (I) echo is executed when sleep is suspended, i.e., command2 is 
>    executed before command1 exits.

This is true, and it's the difference between a process, which is the
object you suspend, and a shell command. When you suspend the sleep,
it returns a status: 128+SIGTSTP. Since this is non-zero, the second
part of the AND-OR list gets executed.

The idiomatic way to do what you want is to get the command you want
to run as a unit into a construct like (...) -- if you want to run it
in the foreground -- so you have a single process that you can suspend.

This has come up many times, in the context of compound commands like
loops and command sequences.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to