Bug 28007

Summary: added "force printing of non-print chars" flag to /bin/ls
Product: Base System Reporter: Jordan.DeLong <Jordan.DeLong>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Jordan.DeLong 2001-06-10 09:00:09 UTC
	when the output of /bin/ls is not to a terminal, it defaults to
	printing non-printable characters directly.  However, when output
	is to a tty there is no way to make it output non-printable chars.

	/bin/ls uses isprint() to determine if a character is printable;
	this includes high-bit ascii characters that really are printable
	in some settings, and also includes filenames that have kanji in
	them.  So forcing the raw printing of these characters can be
	desirable even on a tty, particularly for those who use languages
	other than English that make use of characters that don't fall in
	isprint().

	I've added a -w flag to /bin/ls that is used to force raw output
	of nonprintable characters when the output is a tty.

How-To-Repeat: 	Apply the patch in the Fix: section.  The patch is against the
	/usr/src/bin/ls/ tree that is in 4.3-RELEASE.
Comment 1 Peter Pentchev 2001-06-11 07:06:41 UTC
On Sun, Jun 10, 2001 at 12:56:42AM -0700, Jordan.DeLong@cx420564-b.tucson1.az.home.com wrote:
> 
> >Number:         28007
> >Category:       bin
> >Synopsis:       added "force printing of non-print chars" flag to /bin/ls
> >Originator:     Jordan DeLong
> >Release:        FreeBSD 4.3-RELEASE i386
> >Organization:
> None
> >Environment:
> System: FreeBSD cx420564-b 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Tue Apr 24 08:33:58 GMT 2001 fracture@cx420564-b:/usr/src/sys/compile/HOBOIV i386
> 
> >Description:
> 	when the output of /bin/ls is not to a terminal, it defaults to
> 	printing non-printable characters directly.  However, when output
> 	is to a tty there is no way to make it output non-printable chars.
> 
> 	/bin/ls uses isprint() to determine if a character is printable;
> 	this includes high-bit ascii characters that really are printable
> 	in some settings, and also includes filenames that have kanji in
> 	them.  So forcing the raw printing of these characters can be
> 	desirable even on a tty, particularly for those who use languages
> 	other than English that make use of characters that don't fall in
> 	isprint().

Correct me if I'm wrong, but doesn't isprint() conform to locale settigs?
I don't know if this works with multibyte characters, but for 8-bit locales
ls(1) certainly does the right thing, due to a setlocale(LC_ALL, "") call
at the very start.

> 	I've added a -w flag to /bin/ls that is used to force raw output
> 	of nonprintable characters when the output is a tty.

Other than the above argumet, yes, such a flag could be useful.

G'luck,
Peter

-- 
This sentence no verb.
Comment 2 fracture 2001-06-11 07:11:43 UTC
On Mon, Jun 11, 2001 at 09:06:41AM +0300, Peter Pentchev wrote:
> 
> Correct me if I'm wrong, but doesn't isprint() conform to locale settigs?
> I don't know if this works with multibyte characters, but for 8-bit locales
> ls(1) certainly does the right thing, due to a setlocale(LC_ALL, "") call
> at the very start.
> 


Actually I discovered this only a few hours ago (I was under the impression
that isprint() was a simple macro that just checked if it was > 32 and < 127
or somesuch).  So I was mistaken and everything is alright on that that front
for /bin/ls.

> > 	I've added a -w flag to /bin/ls that is used to force raw output
> > 	of nonprintable characters when the output is a tty.
> 
> Other than the above argumet, yes, such a flag could be useful.
> 


agreed, I think it could still be useful.

-- 
Jordan DeLong
fracture@allusion.net
Comment 3 joe freebsd_committer freebsd_triage 2001-12-29 00:22:35 UTC
State Changed
From-To: open->closed

Committed to -current.  Thanks.