Ohmyksh: A Framework for OpenBSD's Ksh
github.com
github.com
It has also been a life saver on proprietory UNIX platforms where the default sh was usually the plain sh, with ksh always being available and having the command line editing available («set -o emacs» or «set -o vi») and GNU readline being unavailable. The POSIX shell is effectively ksh.
(Larry Wall)
Not surprisingly, the whole ETL/SFTP workflow got a tad bit slower.
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
void list(char* dir) {
DIR* d;
struct dirent* dp;
if (!(d = opendir(dir))) return;
while ((dp = readdir(d)) != NULL) {
int namelen = strlen(dp->d_name);
if (dp->d_type == DT_DIR) {
if ((strcmp(dp->d_name, ".") == 0) || (strcmp(dp->d_name, "..") == 0)) continue;
char p[1024];
snprintf(p, sizeof(p), "%s/%s", dir, dp->d_name);
list(p);
}
else
if (((dp->d_name[namelen-1] == '1') ||
(dp->d_name[namelen-1] == '2') ||
(dp->d_name[namelen-1] == '3') ||
(dp->d_name[namelen-1] == '4') ||
(dp->d_name[namelen-1] == '5') ||
(dp->d_name[namelen-1] == '6') ||
(dp->d_name[namelen-1] == '7') ||
(dp->d_name[namelen-1] == '8') ||
(dp->d_name[namelen-1] == '9')) &&
(dp->d_name[namelen-2] == '.'))
{ write(1, dp->d_name, namelen-2); write(1, "\n", 1); }
}
closedir(d);
}
int main() {
char* path = getenv("MANPATH");
char* dir;
for (dir = strsep(&path, ":"); dir != NULL; dir = strsep(&path, ":")) { list(dir); }
return 0;
}
To use it, just compile and place in your path (I have it as lsm): set -A complete_man -- $(lsm | sort | uniq)
I wrote it by just copying and slightly modifying the example in the opendir/readdir man page, it can probably be improved.