From fracture@cx420564-b.tucson1.az.home.com  Sun Jun 10 00:59:29 2001
Return-Path: <fracture@cx420564-b.tucson1.az.home.com>
Received: from cx420564-b.tucson1.az.home.com (cx420564-b.tucson1.az.home.com [24.21.112.225])
	by hub.freebsd.org (Postfix) with ESMTP id AF91E37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Jun 2001 00:59:29 -0700 (PDT)
	(envelope-from fracture@cx420564-b.tucson1.az.home.com)
Received: (from fracture@localhost)
	by cx420564-b.tucson1.az.home.com (8.11.3/8.11.3) id f5A7ugx05725;
	Sun, 10 Jun 2001 00:56:42 -0700 (MST)
	(envelope-from fracture)
Message-Id: <200106100756.f5A7ugx05725@cx420564-b.tucson1.az.home.com>
Date: Sun, 10 Jun 2001 00:56:42 -0700 (MST)
From: Jordan.DeLong@cx420564-b.tucson1.az.home.com
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: added "force printing of non-print chars" flag to /bin/ls
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         28007
>Category:       bin
>Synopsis:       added "force printing of non-print chars" flag to /bin/ls
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun 10 01:00:09 PDT 2001
>Closed-Date:    Fri Dec 28 16:22:35 PST 2001
>Last-Modified:  Fri Dec 28 16:22:51 PST 2001
>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().

	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.
>Fix:
	

diff -u -ruN ls-dist/ls.1 ls/ls.1
--- ls-dist/ls.1	Mon Mar  5 03:05:00 2001
+++ ls/ls.1	Sun Jun 10 00:40:31 2001
@@ -43,7 +43,7 @@
 .Nd list directory contents
 .Sh SYNOPSIS
 .Nm
-.Op Fl ABCFGHLPRTWabcdfgiklnoqrstu1
+.Op Fl ABCFGHLPRTWabcdfgiklnoqrstu1w
 .Op Ar
 .Sh DESCRIPTION
 For each operand that names a
@@ -191,6 +191,9 @@
 one entry per line.
 This is the default when
 output is not to a terminal.
+.It Fl w
+Force raw printing of non-printable characters.  This is the default
+when output is not to a terminal.
 .El
 .Pp
 The
@@ -210,7 +213,8 @@
 .Pp
 The
 .Fl B ,
-.Fl b
+.Fl b ,
+.Fl w ,
 and
 .Fl q
 options all override each other; the last one specified determines
diff -u -ruN ls-dist/ls.c ls/ls.c
--- ls-dist/ls.c	Wed Aug 16 12:57:11 2000
+++ ls/ls.c	Sun Jun 10 00:34:22 2001
@@ -163,7 +163,7 @@
 		f_listdot = 1;
 
 	fts_options = FTS_PHYSICAL;
-	while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfgiklnoqrstu")) != -1) {
+	while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfgiklnoqrstuw")) != -1) {
 		switch (ch) {
 		/*
 		 * The -1, -C and -l options all override each other so shell
@@ -268,6 +268,11 @@
 			f_nonprint = 0;
 		        f_octal = 0;
 			f_octal_escape = 1;
+			break;
+		case 'w':
+			f_nonprint = 0;
+			f_octal = 0;
+			f_octal_escape = 0;
 			break;
 		default:
 		case '?':

>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@orbitel.bg>
To: Jordan.DeLong@cx420564-b.tucson1.az.home.com
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/28007: added "force printing of non-print chars" flag to /bin/ls
Date: Mon, 11 Jun 2001 09:06:41 +0300

 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.

From: Jordan DeLong <fracture@allusion.net>
To: Peter Pentchev <roam@orbitel.bg>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/28007: added "force printing of non-print chars" flag to /bin/ls
Date: Sun, 10 Jun 2001 23:11:43 -0700

 --J/dobhs11T7y2rNN
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Mon, Jun 11, 2001 at 09:06:41AM +0300, Peter Pentchev wrote:
 >=20
 > 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 local=
 es
 > ls(1) certainly does the right thing, due to a setlocale(LC_ALL, "") call
 > at the very start.
 >=20
 
 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 fro=
 nt
 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.
 >=20
 > Other than the above argumet, yes, such a flag could be useful.
 >=20
 
 agreed, I think it could still be useful.
 
 --=20
 Jordan DeLong
 fracture@allusion.net
 
 
 --J/dobhs11T7y2rNN
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iEYEARECAAYFAjskYR4ACgkQDrrilS51AZ+h5wCgriEY4vNqu8KI2tNQYKByw8ne
 cBUAn2oWzQKgnZX0XGWYww3fn6Qn5q7o
 =hJL0
 -----END PGP SIGNATURE-----
 
 --J/dobhs11T7y2rNN--
State-Changed-From-To: open->closed 
State-Changed-By: joe 
State-Changed-When: Fri Dec 28 16:22:35 PST 2001 
State-Changed-Why:  
Committed to -current.  Thanks. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28007 
>Unformatted:
