Path: utzoo!utgpu!water!watmath!clyde!att!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: Enviroment (was Re: Yea, but can an Amiga Shell do this....) Message-ID: <8809040955.AA26836@cory.Berkeley.EDU> Date: 4 Sep 88 09:55:50 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 85 :> Just a single slash '/' indicates the parent directory, and although :>I agree with you that this is not compatible with UNIX, I LIKE it *much* :>better than having to type '../'. : :Wrong. A single slash does NOT indicate the parent directory. This is the :Amiga's file system problem--the symbols are context sensitive. Look guy, if you just *THINK* about it you will find that the UNIX ../ can be replaced *exactly* by a single slash: UNIX AMIGA ../x/y /x/y x/../y x//y :The truth: :A colon followed by a slash may be an error (is it assigned to a subdir?) Sure, if you are in the root directory of the device you can't go back. If not (an assigned subdir), you can. So what is the problem? :N+1 non-initial consecutive slashes refers to N parents :N initial slashes refers to N parents :There is no easy way to take the name of a directory and append a file : name to it. What are you talking about? :Tell you what: You give me a routine that will take two names, one a :directory, one a file, and return me a pathname for the file. Handle :ending slashes, null directories, assigned devices, assigned directories, :files beginning with slashes, etc. AND make it usable in CLI scripts. :Then, I will consider the Amiga's file system naming useably clean. What are you talking about? I do this all the time. I don't see how it can be done in UNIX any easier than on the Amiga. ending slashes in UNIX: UNIX allows you to have multiple slashes in a filename (at least, 4.3 BSD does). A/B is equivalent to A//B ... Most people, however, do not consider A//B to be of correct form. On the Amiga, this UNIX-hack is obviously not implemented because the Amiga is more sensible in its solution. null directories I understand. I don't see how assigned devices enters in to it because UNIX doesn't support multiple filesystem roots. Files beginning with slashes? you mean when you specify part of a directory path in the filename? Come on, this is *easy*. Every filerequester in existance does this. You could write it in 1 minute. Now this last part 'usable in CLI scripts'... strange condition. Frankly, the relative merits of the CLI's language being able to support the above algorithm efficiently enough has absolutely no bearing on the merits of the filesystem unto itself. >(under non-v7 unix, this routine is arg1 + "/" + arg2. V7 allowed "" for >current directory, so it would be (*arg1 == 0? "./" : arg1 + "/") + arg2 >(+ == strcat)) Since you are so fond of C, I shall simply outline the routine and let you write it: Assumptions: Assume the two parts (dir and file) are to be considered independant paths in their own right. I.E. if dir ends in a '/' we are specifying the parent directory of something. If you don't like that last assumption, then simply replace "not ':'" with "not ':' and not '/'" in the two line routine below... that is, allow for the 'dumb user' who puts extranious characters in his path specifications. Routine (dir, file) { If dir != "" && last char of dir is not ':', append a '/' to dir Return (dir + file) } Gosh, that was easy. Now if you want to handle other cases, like the 'file' isn't just a filename, but an entire path, that's ok with me... you would add something like "If file contains a ':' then ignore dir". This handles: (1) ending slashes on the dir part (assumes you mean go to parent after resolving rest of dir OR assumes user added extranious char). (2) null directories, (3) assigned devices & dirs (:), (4) files beginning with one or more slashes (assumes you want to go to the N'th parent.. why else put a slash in front of a filename?). (5) usable in CLI scripts?? What kind of condition is this? Just write it in C and provide it as a CLI command. -Matt