[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] cat: open any file name after "--"
From: |
Geyslan G. Bem |
Subject: |
Re: [PATCH] cat: open any file name after "--" |
Date: |
Sat, 6 Jul 2019 10:00:10 -0300 |
On Sat, 6 Jul 2019 at 01:48, Eric Blake <address@hidden> wrote:
>
> On 7/5/19 11:31 PM, Eric Blake wrote:
>
> > If you wish to cat a file named '-' in the current directory, spell it
> > './-' or use an absolute path to that file. That's true of all command
> > line utilities that treat '-' as stdin (not just cat).
>
> For more fun, go figure out why:
>
> grep - - --
> grep [---]
>
> behave the same, regardless of whether you have a file named '-' in your
> current working directory (unless you use shopt -s failglob). And the
> rule on using ./- for a file in the current directory also applies to
> touch, except there '-' means stdout instead of stdin.
Interesting. POSIX 'touch' manual says that both STDIN and STDOUT aren't used.
The unique OPERAND is file: "A pathname of a file whose times shall be
modified."
None mention to '-'. I suppose that GNU 'touch' relies on this:
"Where a utility described in the Shell and Utilities volume of POSIX.1-2017
as conforming to these guidelines is required to accept, or not to accept,
the operand '-' to mean standard input or output,
this usage is explained in the OPERANDS section.
Otherwise, if such a utility uses operands to represent files,
it is implementation-defined whether the operand '-' stands for
standard input (or standard output), or for a file named -."
>
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc. +1-919-301-3226
> Virtualization: qemu.org | libvirt.org
>
--
Regards,
Geyslan G. Bem