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 Subject: bin/28007: added "force printing of non-print chars" flag to /bin/ls Message-ID: <200106100756.f5A7ugx05725@cx420564-b.tucson1.az.home.com>
next in thread | raw e-mail | index | archive | help
>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: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jun 10 01:00:09 PDT 2001 >Closed-Date: >Last-Modified: >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106100756.f5A7ugx05725>