wm: teppich

Download patch

ref: ea23d22ea851a283b91310c6e77d4dcc230f6247
parent: d38c96a3fc6d0dbc47627772aa9ed4cd556bf8ef
author: mkf <mkf@cloud9p.org>
date: Wed Dec 6 19:14:14 EST 2023

ls: add usage

--- a/cmd/ls.c
+++ b/cmd/ls.c
@@ -1,9 +1,15 @@
 #include <u.h>
 #include <libc.h>
 #include <err.h>
-#include <mem.h>
 #include <vfs.h>
 
+static int
+usage()
+{
+	printf("ls: usage: ls [-l] dir\n");
+	return USAGE;
+}
+
 char*
 permtoletter(uint16 perms)
 {
@@ -48,7 +54,10 @@
 	{
 		lflag = 1;
 		argv++;
+		argc--;
 	}
+	if(argc != 2)
+		return usage();
 	
 	fs = getfs(argv[1]);
 	if(fs == nil)
@@ -83,7 +92,6 @@
 		}
 		else
 		{
-
 			printf("%s", f->path);
 			printf("%s\n", f->name);
 		}