Re: [List] Re: Nice easy sed question

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Fri, 12 Sep 2025 22:30:26 UTC
On 9/12/25 17:19, Bob Proulx wrote:
> Frank Leonhardt wrote:
>> Kyle Evans wrote:
>>> The synopsis and usage string don't seem to be based in reality
>>> all the way back to BSD 4.4 Lite, the original usage here is
>>> technically fine.
> ...
>> Yes, exactly! I've sanity checked things in Kernighan and Pike, which is a
>> lot better than the man page but all their examples centre on the 's'
>> command. Thanks, Frank.
> 
> I think the synopsis is about as good as it can get in the document
> format of a manpage.  It is missing a little explanation that says how
> to terminate a, i, c commands and how to chain in multiple commands
> with one following the other.  It wasn't designed to squeeze an entire
> sed program all on one line, at least not all of the time.  There are
> some quite long and pretty gnarly multiline sed programs that are
> unreadable on multiple lines without jamming them all together onto
> one line.
> 

The SYNOPSIS is factually incorrect, though (see https://reviews.freebsd.org/D52495).

We don't do GNU-style permutation of non-option arguments and, as far as I'm aware,
have never done so in getopt(3)[0].  Stating that any options can come after the
script/command will just lead to unexpected behavior, because we treat those as
files rather than restarting option parsing.

Thanks,

Kyle Evans

[0] getopt_long(3) does, though, which is why it recognizes a leading '+' style to
get back to the historical behavior