| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
Tim,
Thanks for replying. But I think you mostly misinterpreted my post.
I quoted from the GNU sed manual, suggesting a rewording of the manual
text, so I think it was clear the post related to GNU sed, not other
versions of sed. Obviously, since I'm asking about Q, the post only
applies to sed versions with Q command (likely just GNU).
I didn't ask about the behavior of i and a, and don't have any confusion
about them. I just used them as examples to show the different behavior
of q and Q under GNU sed. Again, q prints scheduled output, Q doesn't.
The manual fails to document that. I'm just pointing that out,
suggesting it gets fixed, wondering if anything I've missed.
All praiseworthy humor aside, refraining from using arR does not
"suppress" scheduled output, since the output was never scheduled. It's
not that I "don't want scheduled output", I never suggested that. A
better (but equivalent) wording would have been "Q is the only command
that suppresses scheduled output". It's a simple factual statement that
is either true (to my understanding) or false (if I missed something).
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. :)
Daniel
On 5/8/2015 2:41 PM, Tim Chase [email protected] [sed-users] wrote:
> On 2015-05-07 20: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.
>
> Just for the record, I believe that "Q" is a GNU extension. Testing
> on FreeBSD and OpenBSD shows it doesn't support "Q". Also, GNU's
> "az" or "ix" syntax are an extension which should be written
> as
>
> sed -e 'i\
> x' -e 'a\
> z' -q
>
> if you're taking portability into consideration.
>
>> $ 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?
>
> The documentation ("info sed" for GNU's annoying info(1)
> documentation instead of proper man-page documentation</rant>) does
> detail that "a" enqueues for future printing, while "i" prints
> immediately:
>
>
> `a\'
> `TEXT'
> Queue the lines of text which follow this command (each but the
> last ending with a `\', which are removed from the output) to be
> output at the end of the current cycle, or when the next input
> line is read.
>
> `i\'
> `TEXT'
>
> Immediately output the lines of text which follow this command
> (each but the last ending with a `\', which are removed from the
> output).
>
> So I would expect the behavior you see: "i" immediately outputs the
> "x", then the "Q" interrupts the printing of the "y" from stdin, and
> the "z" from the "a" command.
>
>> Also, it seems Q is the only way to suppress scheduled output (from
>> arR). Is that correct?
>
> Well, that and simply refraining from scheduling output that you
> don't want. Sounds like the old
>
> Patient: Doctor, it hurts when I press here!
> Doctor: Well, don't press there.
>
> only with
>
> User: I can't suppress scheduled output unless I use Q!
> Sed: Well, don't schedule output.
>
> :-)
>
> -tkc
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------
> Posted by: Tim Chase <[email protected]>
> ------------------------------------
>