It is mistaken to assume that there is a consistent `echo' available
in all environments.  In my experience `echo' can only be relied upon
for printable characters.  To escape other things requires different
invocations depending on which shell, etc., is being used.  Even
things like the ksh builtin and /bin/echo behave differently on
different platforms.

For what its worth, this is from a script of mine which needs to use
escapes.

    # Look for a version of echo that handles escapes
    if [ `echo "a\062z"` = a2z ]
    then ECHOE="echo"
    elif [ `echo -e "a\062z" 2>&1` = a2z ]
    then ECHOE="echo -e"
    elif [ `print "a\062z" 2>&1` = a2z ]
    then ECHOE="print"
    elif [ `/bin/echo -e "a\062z" 2>&1` = a2z ]
    then ECHOE="/bin/echo -e"
    else ECHOE="/bin/echo"
    fi

A more robust method is to use tr to generate control characters, e.g.

    % echo 'a^b' | tr '^' '\012'
    a
    b

-- 
Pete Forman
Western Geophysical
[EMAIL PROTECTED]

Reply via email to