zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <zefram@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu
Subject: files module fixes
Date: Mon, 17 Mar 1997 18:18:42 GMT	[thread overview]
Message-ID: <5260.199703171818@stone.dcs.warwick.ac.uk> (raw)

-----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-----


                 reply	other threads:[~1997-03-17 18:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5260.199703171818@stone.dcs.warwick.ac.uk \
    --to=zefram@dcs.warwick.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).