Echo

Guy Harris guy at auspex.UUCP
Sun Dec 4 19:02:48 AEST 1988


>The builtin echo (and, I believe, /bin/echo) will operate in either BSD or
>ATT mode depending on which directory comes first.

No, "/bin/echo" doesn't look at PATH.

The model used was that "echo" was a builtin solely for performance
reasons, so the system should act "as if" it were searching PATH for it. 
If it were not built in, "echo" would operate in either V7 or S5 mode
(there is no "ATT mode"; there have been releases from AT&T that exhibit
each of the behaviors - BSD's "echo" just happens to be derived from the
V7 one, not the PWB/S3/S5 one), because it would refer to "/bin/echo" if
"/bin" were first in your path and "/usr/5bin/echo" if "/usr/5bin" were
first in your path.

(The idea was suggested by a comment by Dave Korn, who put something
similar into the Korn shell.)

>The problem is, what if I want /usr/ucb before /usr/5bin in my PATH,
>but also want my echo to recoginze sysV escapes?  I have to do, e.g.:

The same would apply if "echo" weren't built in; you'd have to fix it by
explicitly doing

	/usr/5bin/echo "\tthis is a test\n"

>Sun had the right idea, but poor implementation.  Make your echo work
>either way, but settible according to the value of some environment
>variable (e.g., ECHO=BSD vs. ECHO=ATT).  

The same could apply to other non-built-in commands that behave
differently in different environments.

If you want some particular behavior for compatibility reasons, setting
PATH is the answer. 

If you want some particular behavior for *functionality* reasons, this
suggests that the command in your preferred environment should either
have the additional functionality added to it, if that doesn't break
compatibility, or that a new command be provided in that environment if
augmenting the existing command breaks compatibility.

Unfortunately, modifying "echo" would break compatibility.  The approach
taken by Dave Korn, namely adding a "print" command that provides
additional functionality, would be the ideal in this case.  (Chris
Torek's idea of a "printf" command is another example of that approach.)



More information about the Comp.unix.wizards mailing list