Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
files module fixes
- X-seq: zsh-workers 2996
- From: Zefram <zefram@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: files module fixes
- Date: Mon, 17 Mar 1997 18:18:42 GMT
-----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-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author