Possible bug in SunOS System V echo?

Ian Dall idall at augean.OZ
Thu May 3 15:49:21 AEST 1990


In article <12762 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>In article <14020094 at hpisod2.HP.COM> decot at hpisod2.HP.COM (Dave Decot) writes:
>-If thou requirest special processing beyond simply echoing printing
>-characters followed by a newline, thou shalt use the "printf" utility:
>-    printf "Hi there!\n\nEnter your name: "
>
>Well, that's dumb.  Now I have to support TWO commands, where one would do.
>What sort of standardization is this?

Hmm. Well it might be dumb that we got into the two echo mess, but how else
would we get out?

If *I* was writing the standard, I would define echo to do exactly that
with *no* interpretation of options or escape sequences. If you want a
new line do

	echo "foo bar$NL"

where NL is defined appropriatly, and let the shell put it in for you.
I actually keep a little program like that around (I call it echo_args)
which I find very useful for debugging programs which exec other
programs.

If that were the case, printf would still be required.

The problem is that there is know way of changing echo's default behaviour
without breaking it:

	echo -c foo

should output

	-c foo

and

	echo foo\c

should output

	foo\c



More information about the Comp.unix.wizards mailing list