Path: utzoo!attcan!uunet!wuarchive!emory!mephisto!prism!gt0178a From: gt0178a@prism.gatech.EDU (BURNS,JIM) Newsgroups: comp.unix.shell Subject: Re: How to do file | hold file (now cp) Message-ID: <13611@hydra.gatech.EDU> Date: 13 Sep 90 06:00:30 GMT References: <19911:Sep1113:47:2290@kramden.acf.nyu.edu> Organization: Georgia Institute of Technology Lines: 44 in article <19911:Sep1113:47:2290@kramden.acf.nyu.edu>, brnstnd@kramden.acf.nyu.edu (Dan Bernstein) says: > In article <1990Sep11.040043.14727@chinet.chi.il.us> les@chinet.chi.il.us (Leslie Mikesell) writes: >> In article <15472:Sep1015:27:3190@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >> >Of course the editor should use write-over, as it's conceptually >> >modifying the *same* file. cp is putting a *different* file into the >> >name previously used for the original. >> Ah, but cp should only replace the *contents of the file*. > No. That is not what cp does. cp copies a file with one name into a new > file with a different name. The shell's > is what you use to replace the > contents of a file. The following script demonstrates that neither cp or > change the inode of the original file s (& therefore, both change the *contents* of the file - this is std behavior on 3 systems): + touch s + ll -i s usage.new 123941 -rw-r--r-- 1 gt0178a 0 Sep 13 01:52 s 123818 -rw-r--r-- 1 gt0178a 1280 Sep 11 01:05 usage.new + cp usage.new s + ll -i s usage.new 123941 -rw-r--r-- 1 gt0178a 1280 Sep 13 01:52 s 123818 -rw-r--r-- 1 gt0178a 1280 Sep 11 01:05 usage.new + cat + 1> s 0< /dev/null + ll -i s usage.new 123941 -rw-r--r-- 1 gt0178a 0 Sep 13 01:52 s 123818 -rw-r--r-- 1 gt0178a 1280 Sep 11 01:05 usage.new > Huh? ln is the program that associates a name with a different inode. cp > shouldn't be described this way at all; it associates (a copy of) a > file's contents with a new name. If there's already an association > between that new name and a different file, then cp should either fail > or sever the original association. It most certainly should not preserve > the original association when it's talking about an entirely new file. What do you call the "original association" of the file if not its inode? (Given that both replace the contents.) -- BURNS,JIM Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332 uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a Internet: gt0178a@prism.gatech.edu