Re: Differences between q and Q

"Paolo Bonzini [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>

On 08/05/2015 05:22, [email protected] [sed-users] wrote:
> Concerning q (lower), the GNU sed manual says: Exit sed without
> processing any more commands or input. Note that the current pattern
> space is printed if auto-print is not disabled with the -n options.
> 
> Concerning Q (upper), it says: This command is the same as q, but
> will not print the contents of pattern space.
> 
> I don't write or edit the manual. But those definitions seemed adequate to me.
> 
> Anders Granlund, from Sweden, recently wrote me. Among other helpful
> comments, he pointed out that the qQ definitions and distinction between
> the two are incomplete, because they fail to take into account scheduled
> text (from arR commands).

Adding again the GNU sed maintainer.  This is also correct---and
unintended, because Q *should have* printed scheduled text.

I think it would make sense to make an incompatible change, but that's
up to the maintainer.

Paolo

> Here is a comparison that I think (hope) makes it clear:
> 
> $ echo y | sed -e ix -e az -e q
> x
> y
> z
>  
> $ echo y | sed -e ix -e az -e Q
> x
> 
> q prints scheduled text (in this case, from a). Q does not. So the
> documentation seems incorrect, or at least incomplete. I would suggest q
> might say something like "Note that the current pattern space is printed
> if auto-print is not disabled with the -n options. Also, scheduled text
> is printed." and Q "This command is the same as q, but will not print
> the contents of pattern space, nor any scheduled text." Is original
> definition better, expanded definition, or something else? Any other
> comments?
> 
> Also, it seems Q is the only way to suppress scheduled output (from
> arR). Is that correct?
> 
> Thanks,
> Daniel
> 
> 
> 
> ------------------------------------
> Posted by: [email protected]
> ------------------------------------
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.