GNU bug report logs -
#20542
Differences between q and Q
Previous Next
Reported by: Paolo Bonzini <bonzini <at> gnu.org>
Date: Sun, 10 May 2015 16:02:02 UTC
Severity: normal
Tags: wontfix
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 11/05/2015 04:45, Daniel Goldman wrote:
> Hi Paolo,
>
> You are right that this minor point also affects d, but d doesn't seem
> to suppress output, if that was your point. Of course, d deletes
> PatSpace and ends the script, so AutoPrint does nothing. But the point
> is that d does not suppress scheduled text:
>
> $ echo y | sed -e ix -e az -e d
> x
> z
>
> z (the scheduled text) is still printed. So the definition for d should
> probably be reworded to: "Delete the pattern space; print any scheduled
> output; start next cycle."
Interesting. I would have thought that "d" suppresses the scheduled
text and "D" doesn't. But I was remembering wrong.
In retrospect, "Q" should then _not_ have suppressed the scheduled text.
The idea of "Q" was basically "same as d, but quit instead of starting
the next cycle". I guess horses are out here, or do you think that "Q"
should be fixed?
Paolo
> Of course, the same applies to D - The manual is silent concerning
> scheduled text, possibly implying that it is not printed. It should
> probably say for D: "Otherwise, delete text in the pattern space up to
> the first newline, print any scheduled text, and restart cycle with the
> resultant pattern space, without reading a new line of input."
>
> The c command is also affected. Again, if there happens to be any
> scheduled text (admittedly probably would never happen), it gets printed
> before the next Cycle starts. So the manual should probably say: "After
> printing any scheduled text, a new cycle is started after this command
> is done, since the pattern space will have been deleted."
>
> Thierry Blanc suggested that the i command might be affected. It is not.
> Of course, as documented in the manual, for some reason, i does not
> schedule output, instead immediately prints. Only arR schedule.
>
> This is all rather obscure, of course. In all my years of sed usage,
> these circumstances have never arisen. So I think the manual was
> basically OK before. But it makes sense the manual should get all the
> details right, as the reference document, even if including all the gory
> details bogs things down a bit. FWIW, I am adding the details to any
> future edition of the "Definitive Guide" book, and will list the changes
> on the errata page.
>
> Perhaps equally obscure was the observation that Q is apparently the
> only command that suppresses scheduled output.
>
> If you want me to post again to the sed-users group, I could, or you
> could handle it as you choose. Just let me know your preference.
>
> I hope things are going well there in beautiful Italy. Life goes on fine
> here in Seattle.
>
> Thanks,
> Daniel
>
> On 5/10/2015 8:45 AM, Paolo Bonzini bonzini <at> gnu.org [sed-users] wrote:
>>
>>
>> On 10/05/2015 07:07, Daniel Goldman dgoldman <at> ehdp.com [sed-users] wrote:
>>> Again, to repeat, the purpose of my post (based on emails I received)
>>> was to suggest that the GNU sed manual be corrected to read "Note that
>>> the current pattern space is printed if auto-print is not disabled with
>>> the -n options. Also, scheduled text is printed." for q, and "This
>>> command is the same as q, but will not print the contents of pattern
>>> space, nor any scheduled text." for Q. If anyone has comments on this
>>> admittedly minor correction, that would be great. If no comments, that's
>>> OK too. :)
>>
>> Yes, this is a good change. I'm CCing the current GNU sed maintainer so
>> that he can work it out into a patch.
>>
>> By the way, there is another command ("d") that suppresses scheduled
>> text.
>>
>> Paolo
>>
>>
>> ------------------------------------
>>
>> ------------------------------------
>>
>
This bug report was last modified 8 years and 122 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.