This is a follow up to a patch I submitted yesterday. I've created a patch that necessitates a -O flag (since "O" stands for octal, and it was one of the only available letters ;) to output in similar fashion to 'ls -l', except it also outputs the permissions in octal format. I added the flag at the request that I don't alter any of the working code, also, you can combine to do things like 'ls -gO', 'ls -oO', etc. Here is an example, along with the pasted .diff following:
$ ./ls -O who.c [ 644] -rw-r--r-- 1 mrdurden user 19601 2003-08-18 05:52 who.c
--------------------------- BEGIN PASTE ----------------------------------
--- ls.c Thu Dec 11 18:45:22 2003 +++ newls.c Fri Dec 12 01:16:56 2003 @@ -430,6 +430,9 @@
static int sort_reverse;
+/* Nonzero means to display permissions in octal. -O turns this on */ +static int print_octal_mode = 0; + /* Nonzero means to display owner information. -g turns this off. */
static int print_owner = 1; @@ -1361,7 +1364,7 @@ }
while ((c = getopt_long (argc, argv,
- "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1",
+ "abcdfghiklmnopqrstuvw:xABCDFGHI:LONQRST:UX1",
long_options, NULL)) != -1)
{
switch (c)
@@ -1527,6 +1530,11 @@
set_quoting_style (NULL, literal_quoting_style);
break;+ case 'O':
+ format = long_format;
+ print_octal_mode = 1;
+ break;
+
case 'Q':
set_quoting_style (NULL, c_quoting_style);
break;
@@ -2973,6 +2981,12 @@
p += strlen (p);
}+ if (print_octal_mode)
+ {
+ sprintf(p, "[%4o] ", f->stat.st_mode & 07777);
+ p += strlen (p);
+ }
+
/* The last byte of the mode string is the POSIX
"optional alternate access method flag". */
sprintf (p, "%s %3lu ", modebuf, (unsigned long) f->stat.st_nlink);
@@ -3820,6 +3834,7 @@
-N, --literal print raw entry names (don't treat e.g. control\n\
characters specially)\n\
-o like -l, but do not list group information\n\
+ -O like -l, but list octal permissions\n\
-p, --file-type append indicator (one of /=@|) to entries\n\
"), stdout);
fputs (_("\
--------------------------- END PASTE ----------------------------------
Please let me know if this is acceptable or if it is not, and if not, suggestions as to what I should alter. I've tried to keep everything (including the comments) similar to what is already part of the source.
Thanks again for your time, sorry if I shouldn't have replied directly, but re-contacted bug-coreutils.
I look forward to your reply, Chris Van Nuys
At 08:48 PM 12/11/2003, you wrote:
Chris Van Nuys <[EMAIL PROTECTED]> wrote: > I am submitting a patch for the program 'ls'. This patch changes > the way that 'ls' output's long_output ('ls -l', -g, etc).
It would be better to add a new option to activate this behavior, so as not to break existing code that parses ls's output.
paul
_______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-coreutils
