Possible bug in SunOS System V echo?

Robert Elz kre at cs.mu.oz.au
Thu May 3 02:36:07 AEST 1990


In article <14020094 at hpisod2.HP.COM>, decot at hpisod2.HP.COM (Dave Decot) writes:
> Of course, the uses of echo that were always portable remain so:
>     echo Hello world!
>     echo "This is a variable value: $myvar"
>     echo ""

The 1st and 3rd I agree with, the second one is not portable in
general, it depends on the possible range of values for "$myvar".

If you know that "myvar" is "yes" or "no", or "1", "2", ... then its
fine, but if myvar is random user input, a filename (for myvar in *.c do ...)
or anything else that isn't under total control of the script, then
you can't rely on the second form.

As best as I can tell, there's no easy way to reliably print the value
of an unknown variable using the Sys V echo.

Try

	myvar='\n'

before the 2nd of the above with the V7 (BSD) and Sys V echos.

kre



More information about the Comp.unix.wizards mailing list