standards/70813: [PATCH] ls not Posix compliant
Paul
pprocacci at datapipe.com
Sat Aug 21 22:20:22 PDT 2004
>Number: 70813
>Category: standards
>Synopsis: [PATCH] ls not Posix compliant
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-standards
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Aug 22 05:20:21 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator: Paul
>Release: 5.2.1-RELEASE-p8
>Organization:
datapipe
>Environment:
FreeBSD Lucky 5.2.1-RELEASE-p8 FreeBSD 5.2.1-RELEASE-p8 #0: Tue Jun 29 12:04:24 EST 2004 root at Lucky:/usr/obj/usr/src/sys/LUCKY i386
>Description:
The bin utility 'ls' does not conform to Posix standards. Specially the options
g, n and o.
SHORT DESCIPTIONS from Posix:
-g "The same as -l, except that the owner shall not be written."
-n "The same as -l, except that the owner's UID and GID numbers shall be written
, rather than the associated character strings."
-o "The same as -l, except that the group shall not be written."
Current Desciption from freebsd, man page:
man ls
Please note that, in the manpage for ls, the -n option is currect, however the l
s utility doesn't actually follow the rule.
Also currently, the -o options is used to show the file flags. With my included
patch, I changed it to '-O', but I'm sure you guys would want to keep some comp
atibility somewhere. I just wasn't sure how you guys wanted to implement this,
so I arbitrarily picked an unused letter.
>How-To-Repeat:
ls -g
ls -n
ls -o
>Fix:
http://hostsentry.net/ls.diff
diff -u ls.orig/ls.c ls/ls.c
--- ls.orig/ls.c Sun Aug 22 00:52:45 2004
+++ ls/ls.c Sun Aug 22 00:52:15 2004
@@ -126,8 +126,10 @@
int f_sectime; /* print the real time for all files */
static int f_singlecol; /* use single column output */
int f_size; /* list size in short listing */
+ int f_sgroup; /* Show group on output */
int f_slash; /* similar to f_type, but only for dirs */
int f_sortacross; /* sort across rows, not down columns */
+ int f_sowner; /* Show owner in output */
int f_statustime; /* use time of last mode change */
static int f_stream; /* stream the output, separate with commas */
static int f_timesort; /* sort by time vice name */
@@ -208,6 +210,9 @@
f_singlecol = 0;
f_stream = 0;
break;
+ case 'O':
+ f_flags = 1;
+ break;
case 'x':
f_sortacross = 1;
f_longform = 0;
@@ -259,6 +264,14 @@
f_nosort = 1;
break;
case 'g': /* Compatibility with 4.3BSD. */
+#ifndef COMPAT_43
+ f_longform = 1;
+ f_singlecol = 0;
+ f_stream = 0;
+ f_sowner = 1;
+#else
+ f_sowner = 0;
+#endif
break;
case 'h':
f_humanval = 1;
@@ -277,9 +290,15 @@
break;
case 'n':
f_numericonly = 1;
+ f_longform = 1;
+ f_singlecol = 0;
+ f_stream = 0;
break;
case 'o':
- f_flags = 1;
+ f_longform = 1;
+ f_singlecol = 0;
+ f_stream = 0;
+ f_sgroup = 1;
break;
case 'p':
f_slash = 1;
diff -u ls.orig/ls.h ls/ls.h
--- ls.orig/ls.h Sun Aug 22 00:52:45 2004
+++ ls/ls.h Sun Aug 22 00:52:15 2004
@@ -53,8 +53,10 @@
extern int f_nonprint; /* show unprintables as ? */
extern int f_sectime; /* print the real time for all files */
extern int f_size; /* list size in short listing */
+extern int f_sgroup; /* Show group on output */
extern int f_slash; /* append a '/' if the file is a directory */
extern int f_sortacross; /* sort across rows, not down columns */
+extern int f_sowner; /* Show owner on output */
extern int f_statustime; /* use time of last mode change */
extern int f_notabs; /* don't use tab-separated multi-col output */
extern int f_type; /* add type character for non-regular files */
diff -u ls.orig/print.c ls/print.c
--- ls.orig/print.c Sun Aug 22 00:52:45 2004
+++ ls/print.c Sun Aug 22 00:52:15 2004
@@ -191,9 +191,11 @@
prevdev = sp->st_dev;
}
np = p->fts_pointer;
- (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink,
- sp->st_nlink, dp->s_user, np->user, dp->s_group,
- np->group);
+ (void)printf("%s %u ", buf, dp->s_nlink);
+ if(!f_sowner)
+ (void)printf("%-*s ", dp->s_user, np->user);
+ if(!f_sgroup)
+ (void)printf("%-*s ", dp->s_group, np->group);
if (f_flags)
(void)printf("%-*s ", dp->s_flags, np->flags);
if (f_label)
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-standards
mailing list