9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] walk: properly format permissions
@ 2021-04-04  0:34 Stephen Gregoratto
  2021-04-06 16:00 ` Sigrid Solveig Haflínudóttir
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Gregoratto @ 2021-04-04  0:34 UTC (permalink / raw)
  To: 9front

This patch adds dirmodefmt from fcall.h to pretty-print file
permissions, similarly to ls -l. I didn't notice any performance
degradation.

I hope no-one relied on the old behaviour.

diff -r 4dfbef4fa4ac sys/man/1/walk
--- a/sys/man/1/walk	Sat Apr 03 19:32:47 2021 +0200
+++ b/sys/man/1/walk	Sun Apr 04 10:25:44 2021 +1000
@@ -123,8 +123,6 @@
 .IR ls (1),
 .IR du (1)
 .SH BUGS
-Statfmt character `x' displays permissions as an integer.
-.PP
 Manipulating ifs is a nuisance.
 .PP
 File names are assumed to not contain newlines.
diff -r 4dfbef4fa4ac sys/src/cmd/walk.c
--- a/sys/src/cmd/walk.c	Sat Apr 03 19:32:47 2021 +0200
+++ b/sys/src/cmd/walk.c	Sun Apr 04 10:25:44 2021 +1000
@@ -2,6 +2,7 @@
 #include <libc.h>
 #include <bio.h>
 #include <String.h>
+#include <fcall.h>
 
 int Cflag = 0;
 int uflag = 0;
@@ -70,7 +71,7 @@
 			break;
 		case 'q': Bprint(bout, "%ullx.%uld.%.2uhhx", f->qid.path, f->qid.vers, f->qid.type); break;
 		case 's': Bprint(bout, "%lld", f->length); break;
-		case 'x': Bprint(bout, "%ulo", f->mode); break;
+		case 'x': Bprint(bout, "%M", f->mode); break;
 
 		/* These two  are slightly different, as they tell us about the fileserver instead of the file */
 		case 'D': Bprint(bout, "%ud", f->dev); break;
@@ -250,6 +251,8 @@
 		usage();
 	}ARGEND;
 
+	fmtinstall('M', dirmodefmt);
+
 	if((bout = Bfdopen(1, OWRITE)) == nil)
 		sysfatal("Bfdopen: %r");
 	Blethal(bout, nil);
-- 
Stephen Gregoratto

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] walk: properly format permissions
  2021-04-04  0:34 [9front] walk: properly format permissions Stephen Gregoratto
@ 2021-04-06 16:00 ` Sigrid Solveig Haflínudóttir
  0 siblings, 0 replies; 2+ messages in thread
From: Sigrid Solveig Haflínudóttir @ 2021-04-06 16:00 UTC (permalink / raw)
  To: 9front

Thanks, merged.  I did not find any scripts depending on the old
behavior.  The new one seems to be easier to use when calling from
other scripts, ie matching with grep and so on.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-06 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-04  0:34 [9front] walk: properly format permissions Stephen Gregoratto
2021-04-06 16:00 ` Sigrid Solveig Haflínudóttir

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git