zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: Richard Hartmann <richih.mailinglist@gmail.com>
Cc: zsh-workers@sunsite.dk, 288323@bugs.debian.org
Subject: Re: Debian zsh bug triage
Date: Tue, 30 Dec 2008 09:40:01 +0000	[thread overview]
Message-ID: <20081230094000.GB4921@sc.homeunix.net> (raw)
In-Reply-To: <2d460de70812291246o62169a0bxa7b68ce4aa5be504@mail.gmail.com>

On Mon, Dec 29, 2008 at 09:46:07PM +0100, Richard Hartmann wrote:
[...]
> 2) Unexpected behaviour when stopping a job in a command chain[3]
> 
> Consider this:
> 
> echo one && sleep 10 && echo two
> 
> When stopping `sleep 10`, `echo two` will never be executed, no matter in
> what way you revive `sleep 10`. That is OK as backgrounding `sleep 10`
> will set $? to 20. Yet, with
> 
> echo one ; sleep 10 ; echo two
> 
> the same thing happens. As Bart pointed out[4]:

I don't observe that with 4.3.9-dev-1-cvs1210

And I can see all the shells behaving the same. Am I missing
something again?

> 
> > Given "one && two && three", if "two" stops, the shell has three choices:
> > (1) pretend the command was "{ one && two && three }" and suspend the
> >     entire sublist; or
> > (2) pretend that "two" has returned a status and continue the junction; or

Well, it does return a status, but it also leaves a job stopped
in background.

> > (3) stop the entire shell until "two" is resumed.
> 
> > Choice (1) is undesirable because it subverts the user's intent (if he
> > meant there to be braces, he should have typed them)
> and it puts "three"
> > into a separate process when it might better have been run in the current
> > shell.  Choice (3) is impossible in an interactive shell.  That leaves
> > (2), which is what zsh does, using the signal number as the status.
> 
> Personally, I think 1) would meet most users' expectations, but any of
> the three are OK. Not executing the third command at all is not, imo. Of
> course, if the third command is a rm, mv or some other potentially
> destructive command, it's best to err on the save side, so I can see why
> that was done. If that is a design decission, I will accept that and
> close the bug accordingly. But keep in mind that 1) would be a save
> solution, as well ;)
[...]


When one runs:

cmd1; cmd2

he may intend that to be a little script of two commands.

If one expects <Ctrl-C> to terminate that little script (which zsh,
ksh, pdksh, ash do), one may expect (1) above as well, that is
<Ctrl-Z> to stop that little script.

On the other end, 2 makes even more sense because you'd expect

cmd1; cmd2
to be the same as
cmd1
cmd2

And according to SUSv4, those are two jobs.

According to SUSv4, a job is a shell pipeline. And:

SUSv4> pipeline         :      pipe_sequence
SUSv4>                  | Bang pipe_sequence
SUSv4>                  ;
SUSv4> pipe_sequence    :                             command
SUSv4>                  | pipe_sequence '|' linebreak command
SUSv4>                  ;
SUSv4> command          : simple_command
SUSv4>                  | compound_command
SUSv4>                  | compound_command redirect_list
SUSv4>                  | function_definition

So, in the case of { cmd1; cmd2; }, we've got one job, so one
would expect <Ctrl-Z> to stop the whole job.

But then, in "cmd1; cmd2", according to SUSv4 again, <Ctrl-C>
should only terminate cmd1 as bash does and run cmd2... so
there's a consistency problem here.

-- 
Stéphane


  parent reply	other threads:[~2008-12-30  9:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-29 20:46 Richard Hartmann
2008-12-29 21:19 ` Stephane Chazelas
2008-12-29 23:16   ` Richard Hartmann
2008-12-30  8:54     ` Stephane Chazelas
2008-12-30  9:42     ` Stephane Chazelas
2008-12-30 15:29       ` Richard Hartmann
2008-12-30  9:40 ` Stephane Chazelas [this message]
2009-01-21 16:53 ` Richard Hartmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081230094000.GB4921@sc.homeunix.net \
    --to=stephane_chazelas@yahoo.fr \
    --cc=288323@bugs.debian.org \
    --cc=richih.mailinglist@gmail.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).