Hi Bernhard,

Bernhard Gabler via GNU coreutils Bug Reports <[email protected]>
writes:

> Hello,
>
> today I noticed the following deficiencies in implementation and
> documentation of printf:
>
> (1)
> Built-in help (/usr/bin/printf --help)
>
>     entirely fails to mention the option --.
>     This is even more surprising, as an error message explicitly
> points to the built-in help when that option is used without any
> additional parameters:
>
> $/usr/bin/printf --
> printf: missing operand
> Try '/usr/bin/printf --help' for more information.
>
> (2)
> man page  (commonly: /usr/share/man/man1/printf.1.gz)
>
>     is missing any mention (lest description) of the option --.
>
>
> (3)
> Online-Documentation
> (https://www.gnu.org/software/coreutils/manual/html_node/printf-invocation.html#printf-invocation)
>
>     is missing any mention (lest description) of the option --.
>
>     Though at the end of that documentation page, it says:
>
>         "The only options are a lone --help or --version. See Common
> options
> <https://www.gnu.org/software/coreutils/manual/html_node/Common-options.html>.
> Options must precede operands."
>
>     Now seeing that only three "Common options" do exist, it does not
> seem to make sense that the printf page explicitly mentions only two
> of them  ( --help , --version  ) but not the third ( -- ).
>
>
> Obviously, these deficiencies exist in all languages/translations.

This is a POSIX requirement for programs. Copying their words here [1]:

    Guideline 10:
        The first -- argument that is not an option-argument should be
        accepted as a delimiter indicating the end of options. Any
        following arguments should be treated as operands, even if they
        begin with the '-' character.

A common use of this is to delete file names that start with the "-"
character. We have an example like this in the manual under the 'rm'
command:

    $ ls -- -f
    -f
    $ rm -f
    $ ls -- -f
    -f
    $ rm -- -f
    $ ls -- -f
    ls: cannot access '-f': No such file or directory

Collin

[1] 
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap12.html#tag_12_02



Reply via email to