On Thu, Mar 5, 2020, 02:16 Quentin Rameau <quinq@fifth.space> wrote:
>
> On Thu, 5 Mar 2020 01:42:37 -0800
> Michael Forney <mfor...@mforney.org> wrote:
>
> > >> 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.
>
> Rather it's due to a getopt() limitation with the (not so) special case
> of an empty string option-argument, but I'm not sure why.

This has nothing to do with getopt(). This is about how the shell parses
and splits words into arguments. -d"" is exactly the same as -d. It is
the same word, adding an empty string to the end of a string does not
change that original string. There is no argument to -d there. If you
wanted to -d"" to pass two arguments "-d" and "" then you'd have to
write a new shell to do that. As it stands shells pass on "-d" in argv
when they come across -d"".

Reply via email to