Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: Echo Message-ID: <723@auspex.UUCP> Date: 15 Dec 88 19:34:22 GMT References: <6557@june.cs.washington.edu> <960@etnibsd.UUCP> <3331@mipos3.intel.com> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 37 >Will it not work to do ... > >PATH=/usr/5bin:$PATH echo "\tthis is a test\n" > >... since PATH will be different for the execution of only the "echo" >command? Yes, it'll work, at least under SunOS 4.0, *but* it also sets PATH within the shell that you're running! The problem is probably that "echo" is a built-in, so no child process is spawned to run it, and thus the PATH-mashing is done in the process running the main shell. I don't have a vanilla S5 system on which to try this (it won't change the behavior of "echo", but it should test whether PATH gets smashed or not), and some amount of environment-fiddling was changed around a bit in SunOS 4.0 to fix another bug, so I don't know if the bug is Sun's or AT&T's. Doing (PATH=/usr/5bin:$PATH echo "\tthis is a test\n") provides a workaround; this also "does what you want", at least under SunOS 4.0, and doesn't smash PATH; the parentheses force the "echo" to be done in a subshell, and probably forces PATH to be modified there as well. >Also, your second line *expands* PATH, and doesn't set it. Yes, but sticking "/usr/5bin" at the front is sufficient for his purposes. This may all be fixed in S5R4, if it has the Korn shell; I think the "print" command can be made to either behave like the V7 "echo", behave like the S3/S5 "echo", or exhibit other behavior (I think that in the Korn shell "echo" is set up as an alias for "print" with some particular options - in the later versions, I think it checks where "echo" would be found given the value of PATH and sets up the alias appropriately).