[Top][All Lists]

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

Re: readlink: no mention of "--" option

From: Eric Blake
Subject: Re: readlink: no mention of "--" option
Date: Mon, 8 Jan 2018 06:56:23 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

On 01/07/2018 05:00 AM, Oliver Lange wrote:
> Hi everyone,
> Just wanted to mention that neither the --help msg nor the man page for
> readlink mention the apparent support for the "--" option to stop
> interpreting further args as possible command options.

Thanks for the report.  However, the use of '--' to end option arguments
is required by POSIX to work for almost ALL applications (not just
coreutils), so we haven't bothered to document it for individual
applications, on the assumption that it is better to document that
behavior at a system-wide level.  Any program that uses getopt() will
obey that idiom, so the man page for getopt(3) is such a system-wide place.

You are correct that the document should mention the
trick up front - and it does, in the "Common options" section 2:

     Print a usage message listing all available options, then exit

     Print the version number, then exit successfully.

     Delimit the option list.  Later arguments, if any, are treated as
     operands even if they begin with ‘-’.  For example, ‘sort -- -r’
     reads from the file named ‘-r’.

I will note that there are a couple of POSIX-based exceptions for
historical reasons; for example, 'echo' must NOT interpret '--' as end
of options, and you are better off using 'printf' than 'echo' if you
need to output a string that starts with a dash.

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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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