bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: GNU patch not completely posix compliant in --posix mode


From: Paul Eggert
Subject: Re: GNU patch not completely posix compliant in --posix mode
Date: Fri, 30 Nov 2001 15:39:50 -0800 (PST)

> The POSIX specs for the patch utility say:
>  (POSIX 2, page 588, section 5.22.7.2, part (1))
> # If the patch contains the strings *** and ---, the patch utility shall
> # strip components from the beginning of each pathname (depending on the
> # presence or value of the -p option), then test for the existence of
> # both files in the current directory (or the directory specified by
> # the -d option). If both files exist, the patch utility shall assume
> # that no pathname can be obtained from this step.

That part of POSIX.2-1992 is obsolescent.  GNU "patch" attempts to
conform to the latest POSIX draft, not with POSIX.2-1992.  That
appears to explain the discrepancy that you're observing.

Here is the contents of the "Filename Determination" part of the
latest POSIX draft (POSIX 1003.1-200x Draft 7).

  If no file operand is specified, patch shall perform the following
  steps to determine the filename to use:

    1. If the type of diff is context, the patch utility shall delete
        pathname components (as specified by the -p option) from the
        filename on the line beginning with "***", then test for the
        existence of this file relative to the current directory (or
        the directory specified with the -d option). If the file
        exists, the patch utility shall use this filename.

    2. If the type of diff is context, the patch utility shall delete
        the pathname components (as specified by the -p option) from
        the filename on the line beginning with "- - -", then test for
        the existence of this file relative to the current directory
        (or the directory specified with the -d option). If the file
        exists, the patch utility shall use this filename.
        
    3. If the header information contains a line beginning with the
        string Index:, the patch utility shall delete pathname
        components (as specified by the -p option) from this line,
        then test for the existence of this file relative to the
        current directory (or the directory specified with the -d
        option). If the file exists, the patch utility shall use this
        filename.
        
    4. If an SCCS directory exists in the current directory, patch
        shall attempt to perform a get -e SCCS/s.filename command to
        retrieve an editable version of the file. If the file exists,
        the patch utility shall use this filename.
        
    5. The patch utility shall write a prompt to standard output and
        request a filename interactively from the controlling terminal
        (for example, /dev/tty).


> However, GNU patch (with --posix specified) will use the --- (OLD)
> name even if both old and new files exist; that is, it's not following
> the last sentence of the quoted paragraph.

I assume you meant "*** (OLD)" and not "--- (OLD)", as *** is the
marker for old files in context diffs.  As you can see, GNU patch here
is conforming to step (1) of the latest POSIX draft.



reply via email to

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