diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-06-18 19:49:01 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-06-18 19:49:01 -0700 |
commit | 81fed70379578f4fe6255fdf33699675179ffe91 (patch) | |
tree | 5518ee17eb5781ee7e50454f5805599fd8388fce /sys/cmd/ls/ls.c | |
parent | d62e5c1df92ee159d0203b75adebb50faf45badb (diff) |
feat: small coreutils added
Diffstat (limited to 'sys/cmd/ls/ls.c')
-rw-r--r-- | sys/cmd/ls/ls.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sys/cmd/ls/ls.c b/sys/cmd/ls/ls.c new file mode 100644 index 0000000..86aaa48 --- /dev/null +++ b/sys/cmd/ls/ls.c @@ -0,0 +1,36 @@ +#include <u.h> +#include <libn.h> + +static struct Flags { + uchar a : 1; /* show all files */ + uchar r : 1; /* reverse sort */ + uchar v : 1; /* print detailed information */ + uchar h : 1; /* human readable */ + uchar s : 1; /* sort by size */ +} flag; + +static +void +usage(void) +{ + fputs("usage: ls [-ahsrv] [file ...]\n", stderr); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + int i; + ARGBEGIN{ + case 'a': flag.a++; break; + default: + usage(); + }ARGEND; + + switch(argc) { + case 0: + *--argv = ".", ++argc; + /* fallthrough */ + case 1: + } +} |