Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.bugs,net.bugs.usg Subject: SysN test != V7 test Message-ID: <3698@utzoo.UUCP> Date: Fri, 30-Mar-84 17:13:51 EST Article-I.D.: utzoo.3698 Posted: Fri Mar 30 17:13:51 1984 Date-Received: Fri, 30-Mar-84 17:13:51 EST Organization: U of Toronto Zoology Lines: 30 One of the more interesting things done in System N (N = III or V just now) was that "test" is built into the shell. Although we don't run System V, we do run a slightly-modified System V shell on our V7. We have just discovered a very interesting thing: the test(1) command that is built into the shell is not quite the same as the old separate program. The difference is that the old test(1) tested for accessability by trying to open the file. The in-shell one just uses access(2) to look at the permission bits. What difference is there, you ask? Well... There's a minor difference in the case of "test -w directory". This isn't too important, and the new behavior (actually look at the bits rather than just bouncing it regardless) is arguably better. The *real* fun is when you are doing a test(1) on a device. We discovered this because we had a few things that used to do, for example, "test -r /dev/rmt0" to make the magtape rewind. Don't work no more. This breaks things. Not very many things, mind you, and we don't see this as too serious issue. However, consider the following. Shell file, written on System V, does "test -w /dev/rmt0" to see if it's running on a system with a magtape at a suitable name. On a system with the old-style test(1) command, this will write a tape mark at the beginning of the tape, effectively obliterating any data on the tape! Another fun property of using access(2) for test(1) is that access(2) uses the real, not effective, userid. This could make setuid shell files (if you have them -- we don't) *very* interesting. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry