Echo (and how to deal with what you got)

Stan Switzer sjs at jcricket.ctt.bellcore.com
Tue Dec 13 02:13:39 AEST 1988


Regardless of whether you prefer "echo -n" or "echo \c" sometimes you
have to write a shell script that will prompt users correctly
regardless of how echo works.  I have been using the following trick
for a while now, and I figured other people might find it useful:

#!/bin/sh
P1= P2=
if test "`echo -n a; echo b`" = "ab"
then P1="-n"	# BSD style
else P2="\c"	# Sys V style
fi

echo $P1 "A prompt string: "$P2
read RESPONSE

Possibly I picked this trick up from Larry Wall's "rn" configure
script.

Stan Switzer  sjs at ctt.bellcore.com



More information about the Comp.unix.wizards mailing list