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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20542 in the body.
You can then email your comments to 20542 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#20542
; Package
sed
.
(Sun, 10 May 2015 16:02:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paolo Bonzini <bonzini <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Sun, 10 May 2015 16:02:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
bug-sed <at> gnu.org
:
bug#20542
; Package
sed
.
(Sun, 10 May 2015 21:05:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On Sun, 10 May 2015 17:45:14 +0200, Paolo Bonzini <bonzini <at> gnu.org> 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.
Doesn't seem to affect the "a", "i" and "c" commands (I'm not sure this is
as it should be):
$ echo x | sed -e 'a y' -e d
y
$ echo x | sed -e 'i y' -e d
y
$ echo x | sed -e 'c y' -e d
y
$ sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
...
--
D.
Information forwarded
to
bug-sed <at> gnu.org
:
bug#20542
; Package
sed
.
(Mon, 11 May 2015 08:08:02 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
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
>>
>>
>> ------------------------------------
>>
>> ------------------------------------
>>
>
Information forwarded
to
bug-sed <at> gnu.org
:
bug#20542
; Package
sed
.
(Mon, 11 May 2015 22:18:02 GMT)
Full text and
rfc822 format available.
Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):
On 5/11/2015 1:07 AM, Paolo Bonzini wrote:
>
> 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
>
When Anders Granlund wrote me, I also remembered some things wrong. But
I think I was remembering things the way that made sense to me.
--------- Should Q suppress scheduled output?
One could argue that Q means "Bail out immediately". That is what it
does right now, including suppressing scheduled output.
Or one could argue that the decision to schedule output was already made
and should be honored.
If Q was indeed modeled after d, then that is a good reason not to
suppress scheduled output, assuming that d works "correctly".
--------- Does d work correctly?
The original paper by Lee McMahon said - The d function deletes from the
file (does not write to the output) all those lines matched by its
address(es). It also has the side effect that no further commands are
attempted on the corpse of a deleted line; as soon as the d function is
executed, a new line is read from the input, and the list of editing
commands is re-started from the beginning on the new line.
Read literally, "as soon as the d function is executed, a new line is
read from the input" argues that d should suppress scheduled output.
There is no room in that statement for scheduled output to be printed.
On the other hand, I kind of doubt that Lee McMahon had a grand scheme
for everything, had everything planned out.
--------- Maybe i should be scheduled?
I always thought of i and a being closely related. But i does not
schedule output, so is not that close.
Again from the McMahon paper - The i function behaves identically to
the a function, except that <text> is written to the output before the
matched line. All other comments about the a function apply to the i
function as well.
Well, "identically" and "all other comments apply" suggest to me that i
should also schedule output for later. If I was designing the language,
that's how I would do it. Currently, we have:
$ echo y | sed -e ix -e p
x
y
y
So currently, i prints immediately, just like the GNU sed manual says.
But I think it should be like this:
$ echo y | sed -e ix -e p
y
x
y
The proposed alternate would have i schedule to print before AutoPrint
("before the matched line"), analogous to a, and in accord with what was
originally written by McMahon.
------------------- My opinions
I think scheduled output should always get printed. So I think Q should
be "fixed" so that scheduled output is printed.
I think d should stay as it is (print scheduled output), regardless of
possibly mistaken wording by Lee McMahon.
I think i should schedule (not immediately print) output, analogous to
a, and in accord with how the language was apparently intended.
--------------
I have never used Q and probably never will. I do use the i command. But
the suggested change to schedule i output would probably never affect
me, due to the utilitarian way I normally use sed.
In other words, if things stayed as they are right now, as the horses
are already out there, I would be fine with that. I wouldn't want to
break anybody's incredibly imaginative existing sed script.
Thanks,
Daniel
Added tag(s) wontfix.
Request was from
Assaf Gordon <assafgordon <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 25 Jan 2017 03:39:01 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
20542 <at> debbugs.gnu.org and Paolo Bonzini <bonzini <at> gnu.org>
Request was from
Assaf Gordon <assafgordon <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 25 Jan 2017 03:39:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-sed <at> gnu.org
:
bug#20542
; Package
sed
.
(Wed, 25 Jan 2017 03:39:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 20542-done <at> debbugs.gnu.org (full text, mbox):
tags 20542 wontfix
close 20542
stop
Hello Daniel, Paolo and all,
Daniel Goldman wrote:
> In other words, if things stayed as they are right now, as the horses
> are already out there, I would be fine with that. I wouldn't want to
> break anybody's incredibly imaginative existing sed script.
Based on this conclusion, I'm closing this bug and marking it as 'wont
fix'. If things change we can always re-open it.
Thank you for an interesting discussion about sed's internals.
I hope to expand gnu sed's manual soon with information about cycles
and scheduled output, and I'll certainly refer to this thread.
regards,
- assaf
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 22 Feb 2017 12:24:05 GMT)
Full text and
rfc822 format available.
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.