SysV echo
John E Van Deusen III
jiii at visdc.UUCP
Thu May 18 10:49:05 AEST 1989
In article <17548 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
> suppose you are given a shell variable $foo, and need to echo it
> uninterpreted?
>
> There is a solution (albeit ugly):
>
> cat << end
> $foo
> end
For all purists who are almost certainly destined to be dragged into the
SysV world kicking and screaming, let us formalize this solution as the
command eucho. [eu] is from the Greek and means "good", "done easily",
or "true".
cat <<- *eueod
$@
*eueod
> but you may need to do something more. To keep echo from munching
> away backslashes, you might do this:
>
> [ exasperation and shell humor concerning the difficulty of creating a
> suitable shell variable deleted ]
Actually SysV echo does not munch all backslashes, only ones it finds
to its liking; echo '\f\g\h' will output <ff>\g\h<cr>. Is this
unreasonable? The shell, sh(1), also has an inconsistent appetite
for back slashes.
foo=FOO
echo \$foo => $foo
echo `echo \$foo` => FOO
In the second case the backslash was removed as a special treat, because
the expression was contained within accents grave.
--
John E Van Deusen III, PO Box 9283, Boise, ID 83707, (208) 343-1865
uunet!visdc!jiii
More information about the Comp.unix.questions
mailing list