Subject: Re: This has GOT to be a bug in ksh...
To: NetBSD User's Discussion List <netbsd-users@NetBSD.ORG>
From: Greg A. Woods <woods@weird.com>
List: netbsd-users
Date: 06/18/2002 23:40:45
[ On Wednesday, June 19, 2002 at 00:26:13 (+0100), David Laight wrote: ]
> Subject: Re: This has GOT to be a bug in ksh...
>
> > 
> > but then "printf" cannot yet do what "vis -ctl" can (though it wouldn't
> > be hard to fix -- something the opposite of '%b' is all that's really
> > needed, and really printf(3) needs such features too!)
> 
> One of the many print/echo lumps of code I've looked at in the last week
> or so carefully escaped non-printables (or at least doubled up \ chars)
> so that the output would look the same as the input.
> 
> This verison is particularly un-useful (IIRC it was a posix variant!).
> 
> Given that echo is often used for semi-formatted output, the ability
> to generate control characters is actually very useful.
> It is actually much rarer to have \ sequences inside the text
> to be displayed.
> 
> (How many filenames on your system have \ in them?)

Perhaps I didn't communicate the meaning of "opposite" clearly enough:

In the following example we see what %b can do:

	$ printf "%b" "foo\nbar\n"
	foo
	bar
	$ 

What the "opposite" of "%b" would do would be to translate unprintable
characters back into visible escape sequences just as "vis -ctl" does,
so hopefully the following example would work, assuming %B is the
functional opposite of the currently implemented %b:

	$ printf "%B\n" "$(printf "%b" "foo\tbar\t\n")"
	foo\tbar\t
	$ 

(remember command-line substitution would FUBAR the newlines so this
example necessarily deviates from the above one)


-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods@acm.org>;  <g.a.woods@ieee.org>;  <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>