zsh-workers
 help / color / mirror / code / Atom feed
* files module fixes
@ 1997-03-17 18:18 Zefram
  0 siblings, 0 replies; only message in thread
From: Zefram @ 1997-03-17 18:18 UTC (permalink / raw)
  To: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----

This patch makes the behaviour of the files module, when removing existing
files, more like that of the standard commands.

 -zefram

 *** Src/Modules/files.c	1997/01/29 06:10:18	1.12
 --- Src/Modules/files.c	1997/03/17 04:56:52
 ***************
 *** 178,183 ****
 --- 178,184 ----
   #define MV_FORCE  (1<<1)
   #define MV_INTER  (1<<2)
   #define MV_ASKNW  (1<<3)
 + #define MV_ATOMIC (1<<4)
   
   /* bin_ln actually does three related jobs: hard linking, symbolic *
    * linking, and renaming.  If called as mv it renames, otherwise   *
 ***************
 *** 198,203 ****
 --- 199,205 ----
       if(func == BIN_MV) {
   	move = rename;
   	flags = ops['f'] ? 0 : MV_ASKNW;
 + 	flags |= MV_ATOMIC;
       } else {
   	flags = ops['f'] ? MV_FORCE : 0;
   #ifdef HAVE_LSTAT
 ***************
 *** 211,217 ****
   		flags |= MV_NODIRS;
   	}
       }
 !     if(ops['i'])
   	flags |= MV_INTER;
       for(a = args; a[1]; a++) ;
       if(a != args) {
 --- 213,219 ----
   		flags |= MV_NODIRS;
   	}
       }
 !     if(ops['i'] && !ops['f'])
   	flags |= MV_INTER;
       for(a = args; a[1]; a++) ;
       if(a != args) {
 ***************
 *** 276,281 ****
 --- 278,284 ----
   	}
       }
       if(!lstat(qbuf, &st)) {
 + 	int doit = flags & MV_FORCE;
   	if(S_ISDIR(st.st_mode)) {
   	    zwarnnam(nam, "%s: cannot overwrite directory", q, 0);
   	    return 1;
 ***************
 *** 287,293 ****
   	    fflush(stderr);
   	    if(!ask())
   		return 0;
 ! 	} else if((flags & MV_ASKNW) & access(qbuf, W_OK)) {
   	    nicezputs(nam, stderr);
   	    fputs(": replace `", stderr);
   	    nicezputs(q, stderr);
 --- 290,301 ----
   	    fflush(stderr);
   	    if(!ask())
   		return 0;
 ! 	    doit = 1;
 ! 	} else if((flags & MV_ASKNW) &&
 ! #ifdef S_ISLNK
 ! 		!S_ISLNK(st.st_mode) &&
 ! #endif
 ! 		access(qbuf, W_OK)) {
   	    nicezputs(nam, stderr);
   	    fputs(": replace `", stderr);
   	    nicezputs(q, stderr);
 ***************
 *** 296,303 ****
   	    fflush(stderr);
   	    if(!ask())
   		return 0;
   	}
 ! 	if(flags & MV_FORCE)
   	    unlink(qbuf);
       }
       if(move(pbuf, qbuf)) {
 --- 304,312 ----
   	    fflush(stderr);
   	    if(!ask())
   		return 0;
 + 	    doit = 1;
   	}
 ! 	if(doit && !(flags & MV_ATOMIC))
   	    unlink(qbuf);
       }
       if(move(pbuf, qbuf)) {
 ***************
 *** 393,399 ****
   	    fflush(stderr);
   	    if(!ask())
   		return 0;
 ! 	} else if(!ops['f'] && access(rp, W_OK)) {
   	    nicezputs(nam, stderr);
   	    fputs(": remove `", stderr);
   	    nicezputs(arg, stderr);
 --- 402,412 ----
   	    fflush(stderr);
   	    if(!ask())
   		return 0;
 ! 	} else if(!ops['f'] &&
 ! #ifdef S_ISLNK
 ! 		!S_ISLNK(st.st_mode) &&
 ! #endif
 ! 	    	access(rp, W_OK)) {
   	    nicezputs(nam, stderr);
   	    fputs(": remove `", stderr);
   	    nicezputs(arg, stderr);

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: ascii

iQCVAwUBMyzQEnD/+HJTpU/hAQEBBQP/QfCL1ODxwvxlAS9KhsZaIkBF4ChuN83E
PD8XUz+kYSJaCCUhc+WeTsd+6QjgOiulxV12x4JUy31/6s0vDNtAYv/zhnjftQHK
fLUHbxjJCGOVVBhnBH/5hLbJe0/PbUnbLycu9w/xONXbPRWWGTaDNKFzAjtz9RqX
mpkj32LM+Vo=
=vl+7
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-03-17 18:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-17 18:18 files module fixes Zefram

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).