A 2016-10-05T16:49:43 +0900, Kazunobu Kuriyama escreveu:
> 2016-10-05 8:18 GMT+09:00 João Miguel <[email protected]>:
> > A 2016-10-04T22:49:10 +0200, Bram Moolenaar escreveu:
> > > João Miguel wrote:
> > > > While I thought "-" was an option, it actually isn't (see
> > > > http://lists.gnu.org/archive/html/bug-coreutils/2016-10/msg00002.html
> > ).
> > (...)
> > >
> > > If "vim -- -" reads from stdin, then how do you edit a file name "-"?
> > > The current behavior is needed for that.
> > That's what I thought, it was a bug in the coreutils ("cat -- -" does
> > the same as "cat -"). But no, POSIX specifies this precisely (- should
> > be consistent). To open a file named "-", use "vim ./-", the same way
> > you would use "cat ./-" to dump a file's contents to stdout, or "vim
> > ../-" to open a file named "-" in the directory above.
> >
> > The point is, "-" is specified not to be an option by POSIX. If you used
> > getopt, making it an option would actually be impossible (by design). As
> > appealing as it may sound, "vim -- -" should therefore *not* have the
> > effect of "vim ./-" - also note the latter is 1 character shorter.
> >
>
> According to another part of the same document that the coreutils dev
> referred to in reply to your another bug report to bug-coreutils, namely,
> the subsection OPERANDS of 1.4 Utility Description Defaults,
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html,
> they say:
>
> > If an operand naming a file can be specified as '-', which means to use
> the standard input instead of a named file, this is explicitly stated in
> this section.
>
> where, judging from the context around the sentence there, "this section"
> stands for a section called OPERANDS.
>
> Meanwhile, Vim explicitly states it in the section of OPTIONS of vim(1)
> like this:
>
> > -- Denotes the end of the options. Arguments after this will
> be handled as a file name. This can be used to edit a filename that
> starts with a '-'.
Actually, this is not the place where "an operand naming a file can be
specified as '-'". The place where that happens is the DESCRIPTION
section (should be in OPERANDS as you mentioned, but compliance with the
rule of information being in the expected section is not a bug in vim,
but in the manual, and not a serious problem):
- The file to edit is read from stdin. Commands are
read from stderr, which should be a tty.
So as POSIX goes, the program can decide whether the "-" means to read a
file with that name or stdin. However, once you've decided on what to
do, since "-" is not an option (as mentioned in the said document, 12.2,
guideline 13:
For utilities that use operands to represent files to be opened for
either reading or writing, the '-' operand should be used to mean
only standard input (or standard output when it is clear from
context that an output file is being specified) or a file named -
), you ought to abide by the decision. It refers to "the '-' operand",
and you cannot just pretend it is an option by using "--" to change its
behaviour.
> True, there's an obvious difference in section names to have used. Apart
> from that, Vim seemingly complies with the standard in an allowable
> deviation, IMHO.
Sorry if I'm being pedantic, but I beg to differ, that's not compliance.
I mean, either the folks from coreutils are right, or you are. When I
initially came to them, I would have agreed with you. But POSIX says I
was wrong, no room for my interpretation of "-" as an option. And as I
think it is important to follow the standard, for everyone to know what
to expect from a program without RTFM for every option; I consider this
to be a bug. Not one introduced by accident or carelessness, but by a
misunderstanding regarding POSIX: after all, what's the point of having
a well-defined standard if it is not to be followed?
TL;DR: "-" is *defined* and treated as an operand by POSIX, coreutils,
getopt, ed, etc., and should get the same treatment from vim if vim is
to be POSIX-compliant.
Best regards,
João Miguel
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.