aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/ls/ls.c
blob: 86aaa482eba78b12c6c251bc82247a40dda8bdd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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:
    }
}