bugGNU patch - Bugs: bug #28454, patch shouldn't operate on...

 
 

bug #28454: patch shouldn't operate on read-only files

Submitter:  Christoph Berg <myon>
Submitted:  Thu 31 Dec 2009 06:25:38 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 29 Apr 2010 11:21:28 PM UTC, comment #1: 

I added this to the Debian bug:

> IMO an appropriate thing to do for patch would be to refuse to
> modify read-only files unless -f (--force) or -t (--batch) is
> given, and warn otherwise.  The current behavior is just wrong.
>
> This will make it POSIX compliant, and hopefully it will not be
> such a big deal in build environments, which may be using -f
> already.  (In build environments, the interactive questions are
> of no use, anyway.)
>
> Any objections?

Andreas Gruenbacher <agruen>
Group administrator
Thu 31 Dec 2009 06:25:38 PM UTC, original submission:  

From http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=274079:

$ cat > ordered
1
2
3
$ cat > misordered
1
2000
3
$ chmod -w *ordered ; ls -l *ordered
-r--r--r--  1 rob rob 9 Sep 29 13:55 misordered
-r--r--r--  1 rob rob 6 Sep 29 13:54 ordered
$ diff -u ordered misordered | patch ordered
patching file ordered
$ ls -l *ordered
-r--r--r--  1 rob rob 9 Sep 29 13:55 misordered
-r--r--r--  1 rob rob 9 Sep 29 14:01 ordered

This is TOTALLY broken.  Patch should fail with a "Permission denied,"
not change my read-only file.

-----------

From: Paul Eggert <eggert@CS.UCLA.EDU>
Subject: Re: Bug #274079: patch shouldn't operate on read-only files!
Date: Sun, 10 Oct 2004 21:25:32 -0700

Michael Fedrowitz <michaelf@debian.org> writes:

> On Wed, Sep 29, 2004 at 02:04:34PM -0400, Rob Mahurin wrote:
>> This is TOTALLY broken.  Patch should fail with a "Permission denied,"
>> not change my read-only file.


I tend to agree.  POSIX requires the behavior that you prefer: "patch"
does not conform to POSIX here.

> it might break any number of package's builds (it's not unusual to find
> files with all kinds of weird permissions in source tarballs).


I also agree with this.  So unfortunately we are a bit stuck
between a rock and a hard place.

Clearly "patch" should conform to POSIX if POSIXLY_CORRECT is set.
(Anybody want to contribute a fix?)  Other than that, I'm not sure
what it should do, to be honest.

Christoph Berg <myon>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by agruen (Posted a comment)
  • -email is unavailable- added by myon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-09-17 agruen StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code