Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!rutgers!cbmvax!jesup From: jesup@cbmvax.UUCP (Randell Jesup) Newsgroups: comp.sys.amiga Subject: Re: Enviroment (was Re: Yea, but can an Amiga Shell do this....) Message-ID: <4660@cbmvax.UUCP> Date: 4 Sep 88 08:21:31 GMT References: <8808232121.AA28517@cory.Berkeley.EDU> <10580@stb.UUCP> Reply-To: jesup@cbmvax.UUCP (Randell Jesup) Organization: Commodore Technology, West Chester, PA Lines: 61 In article <10580@stb.UUCP> michael@stb.UUCP (Michael) writes: >A colon followed by a slash may be an error (is it assigned to a subdir?) It is an error. >N+1 non-initial consecutive slashes refers to N parents >N initial slashes refers to N parents It's all a matter of how of how you tokenize (in your mind or otherwise) the pathname. If you (in your mind) include the / at the end of a directory name, it makes sense. Think of walking through the path left to right, handling it as you go. >There is no easy way to take the name of a directory and append a file > name to it. Define easy. >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. ok char *foo (char *dir,char *file) { /* I assume dir can be extended here */ int dirlen = strlen(dir); char lastchar; if (dirlen) { lastchar = dir[dirlen-1]; if (lastchar != ':' && lastchar != '/') strcat(dir,"/"); } strcat(dir,file); return dir; } It can be much more efficient, but I wrote for clarity. As for "use in shell scripts", I don't understand you at all. Which shell, used how? AmigaDos CLI, AmigaDos Shell (1.3), Dillon's shell, TShell, Wsh, something else? File _names_ cannot have slashes in them (by definition). >(under non-v7 unix, this routine is arg1 + "/" + arg2. V7 allowed "" for >current directory, so it would be (*arg1 == 0? "./" : arg1 + "/") + arg2 >(+ == strcat)) It's more complicated than unix, but then it supports removable media better than Unix does, and I (for one) find it easier to deal with than typing 3 characters per directory up, instead of one. This is especially true when combined with a shell that does an implicit cd when you type a directory name. -- Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup