aboutsummaryrefslogtreecommitdiffstats
path: root/usr/help.c
blob: 5a68d5725476543bffd209516b87f20a319a115d (plain) (blame)
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
#include "gbos.h"
/* help: list every command the shell knows. The kernel owns the name table
 * (sys_lookup searches it), so walk program ids and ask for each one's name -
 * the box had no way to discover what it can do. */
void main(void) {
    char name[16];
    unsigned char id, col = 0;
    for (id = 0; id < 64; id++) {
        name[0] = 0;
        progname(id, name);
        name[15] = 0;
        if (!name[0]) continue;
        if (lookup(name) == NOFD) continue; /* not reachable from the shell */
        puts(name);
        col = (unsigned char)(col + 1);
        if (col == 4) {
            nl();
            col = 0;
        } else {
            unsigned char k = strlen(name);
            while (k++ < 10) putc(' ');
        }
    }
    if (col) nl();
}