Re: [hackers] [PATCH][sbase] paste: Allow null delim

From: Michael Forney <mforney_AT_mforney.org>
Date: Thu, 5 Mar 2020 01:42:37 -0800

On 2020-03-05, Quentin Rameau <quinq_AT_fifth.space> wrote:
>> Looking at POSIX, I see that `-d '\0'` must be supported, `-d ""` is
>> unspecified
>
> I don't think so, -d "" is just a list with an empty string.
> So -d '\0' is equivalent to -d '', '\0' is here to let the user express
> an empty string in a list, which wouldn't be possible otherwise (like
> how would one specify empty string in a list like 'ab<empty-string>cd').

Here is a direct quote from POSIX:

    The commands:

    paste -d "\0" ...
    paste -d "" ...

    are not necessarily equivalent; the latter is not specified by
this volume of POSIX.1-2017 and may result in an error.

>> and `-d""` is invalid, since paste(1) must follow the
>> utility syntax guidelines (guideline 7).
>
> Not sure what you mean there, -d"" is the concatenation of -d and '',
> which is standard.
> Did you quote the correct guideline? “Guideline 7: Option-arguments
> should not be optional.” here there's an option-argument, that's an
> empty string.

I guess it's a combination of 6 and 7. Option arguments must be
separate parameters and non-optional (unless specified otherwise).
There is an exception made that allows conforming implementations to
accept an option adjacent with its option argument in the same
argument, but I think this only makes sense if the option-argument is
non-empty.

POSIX says

  The construct '\0' is used to mean "no separator" because historical
versions of paste did not follow the syntax guidelines, and the
command:

  paste -d"" ...

  could not be handled properly by getopt().

I think this implies that `paste -d""` is no longer valid, due to the
requirements of the syntax guidelines.
Received on Thu Mar 05 2020 - 10:42:37 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 05 2020 - 10:48:36 CET