Subject: Re: discrepency beteen /bin/echo and builtin echo of /bin/sh
To: NetBSD Userlevel Technical Discussion List <firstname.lastname@example.org>
From: Greg A. Woods <email@example.com>
Date: 06/12/2002 16:47:32
[ On Wednesday, June 12, 2002 at 15:48:57 (-0400), der Mouse wrote: ]
> Subject: Re: discrepency beteen /bin/echo and builtin echo of /bin/sh
> > That's just plain silly. It is not important or necessary for "echo"
> > to support '--'. "-n" is defined to be only recognized if it is the
> > _FIRST_ operand.
> So, how do you get echo to produce the three characters '-', 'n', '\n'
> as output?
(I often assume 'echo' will know about '\c', though you'll find tricks
to avoid this assumption in my ~/.profile)
> For that matter, how do you take a user-supplied string
> (which might be "-n") and echo it? (echo -n "$stuff"; echo "") seems
> awfully ugly.
Usually I just do:
echo "" "$user_stuff"
and if a leading space is not desired, and output is to the user's TTY
(not some data file), then I use CTRL-B:
echo " ^b" "$user_stuff"
or I use printf (perhaps from in awk if there's no printf(1))! :-)
Greg A. Woods
+1 416 218-0098; <firstname.lastname@example.org>; <email@example.com>; <firstname.lastname@example.org>
Planix, Inc. <email@example.com>; VE3TCP; Secrets of the Weird <firstname.lastname@example.org>