[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] cat: open any file name after "--"

From: Eric Blake
Subject: Re: [PATCH] cat: open any file name after "--"
Date: Fri, 5 Jul 2019 23:31:06 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 7/5/19 11:16 PM, Geyslan G. Bem wrote:
>>From 99ed9353c43fc8682f99a70d8a0b97d75f78f3f8 Mon Sep 17 00:00:00 2001
> From: "Geyslan G. Bem" <address@hidden>
> Date: Sat, 6 Jul 2019 01:04:40 -0300
> Subject: [PATCH] cat: open any file name after "--"
> * src/cat.c (main): Treat "-" after "--" as file, not as stdin.

Sorry, but this patch violates POSIX.

"If a file is '-', the cat utility shall read from the standard input at
that point in the sequence."

Note that [file...] per the SYNOPSIS is NOT an option, but an argument.
The '--' argument is an end-of-option marker, required only when you
want the next command line word (or all subsequent command line words
when you are not using POSIXLY_CORRECT to suppress GNU getopt argument
permutation) to be recognized as an argument rather than an option.  But
since there is no such thing as an empty-string option, '-' is not
recognized as an option in the first place, regardless of whether or not
'--' was present.

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).

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization: |

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]