Re: man sed(1): instructions wrt whitespace in functions

2022-09-15 Thread Jason McIntyre
On Wed, Sep 14, 2022 at 11:51:41AM +0200, Luka Krmpoti?? wrote:
> section "DESCRIPTION" of sed man(1) page, says
> >The form of a sed command is as follows:
> >[address[,address]]function[arguments]
> >Whitespace may be inserted before the first address and the function
> >portions of the command.
> https://github.com/openbsd/src/blob/16748403c325ab5b4e9457bf8f0879a6698daba9/usr.bin/sed/sed.1#L138-L139
> 
> I don't understand where this whitespace would go, perhaps it should say:
> >Whitespace may be inserted between the address and the function
> >portions of the command.
> 

hi.

i think you should send a diff to say what you think it should say.

jmc

> if I use a `-f command_file` I tested that I can indeed insert a whitespace
> between address & function portions, e.g. `1,3p` as well as `1,3 p` work.
> 
> For this and the following mentions of whitespace, I have not managed
> to make whitespace work when command was given as an argument
> (either alone or part of -e flag). In my tests, I could insert whitespaces
> in sed commands only in `command_file`. This behavior is not mentioned
> in the man page.
> 
> section "SED FUNCTIONS":
> >The r and w functions, as well as the w flag to the s function, take a
> >file parameter, which should be separated from the function or flag by
> >whitespace.
> 
> The r & w & s (with w flag) functions work also if file parameter is NOT
> separated, while
> if it IS separated by whitespace, they only work as part of `command_file`.
> 
> perhaps, the instruction should read something like
> >The r and w functions, as well as the w flag to the s function, take a
> >file parameter, which can be separated from the function or flag by
> >whitespace in `command_file`.
> 
> I haven't looked into IEEE specification, perhaps the word "should"
> applies to that, and the sentence should be left as is.
> 
> then we have
> >The b, r, s, t, w, y, and : functions all accept additional arguments.
> >The synopses below indicate which arguments have to be separated from the
> >function letters by whitespace characters.
> >
> >[2addr]b [label]
> >[1addr]r file
> >[2addr]s/RE/replacement/flags
> >[2addr]t [label]
> >[2addr]w file
> >[2addr]y/string1/string2/
> >[0addr]:label
> 
> again, (b,r,s,t,w) functions work without whitespace separation of
> arguments,
> while with whitespace only as part of `command_file`
> so why does it say `have to` (again, maybe because of IEEE spec?).
> 
> maybe the wording should be
> >The b, r, s, t, w, y, and : functions all accept additional arguments.
> >The synopses below indicate which arguments can be separated from the
> >function letters by whitespace character in `command_file`
> 
> In short, it is frustrating for someone learning sed, testing the sed
> functions using
> command argument (alone or part of -e), to be told to insert whitespace
> when this only works as part of `command_file`.
> 
> Best,
> Luka
> 
> P.S.
> I appreciate my suggestions getting replies, unfortunately I'm struggling
> with mail. I don't receive any replies in my inbox, and have to check
> https://marc.info/?l=openbsd-tech to see them.



man sed(1): instructions wrt whitespace in functions

2022-09-14 Thread Luka Krmpotić
section "DESCRIPTION" of sed man(1) page, says
>The form of a sed command is as follows:
>[address[,address]]function[arguments]
>Whitespace may be inserted before the first address and the function
>portions of the command.
https://github.com/openbsd/src/blob/16748403c325ab5b4e9457bf8f0879a6698daba9/usr.bin/sed/sed.1#L138-L139

I don't understand where this whitespace would go, perhaps it should say:
>Whitespace may be inserted between the address and the function
>portions of the command.

if I use a `-f command_file` I tested that I can indeed insert a whitespace
between address & function portions, e.g. `1,3p` as well as `1,3 p` work.

For this and the following mentions of whitespace, I have not managed
to make whitespace work when command was given as an argument
(either alone or part of -e flag). In my tests, I could insert whitespaces
in sed commands only in `command_file`. This behavior is not mentioned
in the man page.

section "SED FUNCTIONS":
>The r and w functions, as well as the w flag to the s function, take a
>file parameter, which should be separated from the function or flag by
>whitespace.

The r & w & s (with w flag) functions work also if file parameter is NOT
separated, while
if it IS separated by whitespace, they only work as part of `command_file`.

perhaps, the instruction should read something like
>The r and w functions, as well as the w flag to the s function, take a
>file parameter, which can be separated from the function or flag by
>whitespace in `command_file`.

I haven't looked into IEEE specification, perhaps the word "should"
applies to that, and the sentence should be left as is.

then we have
>The b, r, s, t, w, y, and : functions all accept additional arguments.
>The synopses below indicate which arguments have to be separated from the
>function letters by whitespace characters.
>
>[2addr]b [label]
>[1addr]r file
>[2addr]s/RE/replacement/flags
>[2addr]t [label]
>[2addr]w file
>[2addr]y/string1/string2/
>[0addr]:label

again, (b,r,s,t,w) functions work without whitespace separation of
arguments,
while with whitespace only as part of `command_file`
so why does it say `have to` (again, maybe because of IEEE spec?).

maybe the wording should be
>The b, r, s, t, w, y, and : functions all accept additional arguments.
>The synopses below indicate which arguments can be separated from the
>function letters by whitespace character in `command_file`

In short, it is frustrating for someone learning sed, testing the sed
functions using
command argument (alone or part of -e), to be told to insert whitespace
when this only works as part of `command_file`.

Best,
Luka

P.S.
I appreciate my suggestions getting replies, unfortunately I'm struggling
with mail. I don't receive any replies in my inbox, and have to check
https://marc.info/?l=openbsd-tech to see them.