diff -u zsh-4.0.7/Src/builtin.c zsh-4.0.7-help/Src/builtin.c --- zsh-4.0.7/Src/builtin.c 2003-05-07 11:28:23.000000000 +0200 +++ zsh-4.0.7-help/Src/builtin.c 2003-11-14 14:26:38.000000000 +0100 @@ -73,6 +73,7 @@ BUILTIN("hashinfo", 0, bin_hashinfo, 0, 0, 0, NULL, NULL), #endif + BUILTIN("help", 0, bin_help, 0, -1, 0, NULL, NULL), BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "nrdDfEim", "l"), BUILTIN("integer", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "Hghilrtux", "i"), BUILTIN("jobs", 0, bin_fg, 0, -1, BIN_JOBS, "dlpZrs", NULL), @@ -1202,6 +1203,50 @@ } } +/* bin_help */ + +/**/ +int +bin_help(char *nam, char **argv, char *ops, int func) +{ + /* + * look the explanation up in /usr/share/zsh/help + * and print it on stdout + */ + + char *helpfile = NULL; + char *line = NULL; + FILE *help = NULL; + size_t j = 0; + + if ( argv[0] == NULL ) + return 1; + + helpfile = (char*)zalloc(strlen("/usr/share/zsh/help/") + strlen(argv[0]) + 1); + sprintf(helpfile,"/usr/share/zsh/help/%s",argv[0]); + + /* open the file, if that works print out the contents to screen */ + help = fopen(helpfile, "r"); + zfree(helpfile, 0); + if ( help == NULL ) { + zwarnnam(nam, "no help available for: %s", argv[0], 0); + return 1; + } + + + line = (char*)zalloc(90); /* 90 bytes per line should be enough */ + + /* getline, does some resizing of its own --- *frown* */ + while ( getline(&line, &j, help ) != 1 ) + printf("%s",line); + + zfree(line,90); /* this could be too little... */ + fclose(help); + + return 0; +} + + /**** history list functions ****/ /* fc, history, r */ diff -u zsh-4.0.7/Src/builtin.epro zsh-4.0.7-help/Src/builtin.epro --- zsh-4.0.7/Src/builtin.epro 2003-11-14 14:42:45.000000000 +0100 +++ zsh-4.0.7-help/Src/builtin.epro 2003-11-14 14:40:36.000000000 +0100 @@ -17,6 +17,7 @@ extern int fixdir _((char*src)); extern mod_import_function void printqt _((char*str)); extern mod_import_function void printif _((char*str,int c)); +extern int bin_help _((char*nam,char**argv,char*ops,int func)); extern int bin_fc _((char*nam,char**argv,char*ops,int func)); extern Param typeset_single _((char*cname,char*pname,Param pm,int func,int on,int off,int roff,char*value,Param altpm)); extern int bin_typeset _((char*name,char**argv,char*ops,int func)); Binary files zsh-4.0.7/Src/builtin.o and zsh-4.0.7-help/Src/builtin.o differ Common subdirectories: zsh-4.0.7/Src/Builtins and zsh-4.0.7-help/Src/Builtins diff -u zsh-4.0.7/Src/builtin.syms zsh-4.0.7-help/Src/builtin.syms --- zsh-4.0.7/Src/builtin.syms 2003-11-14 14:42:45.000000000 +0100 +++ zsh-4.0.7-help/Src/builtin.syms 2003-11-14 14:40:36.000000000 +0100 @@ -27,6 +27,7 @@ Eextern mod_import_function void printqt _((char*str)); Xprintif Eextern mod_import_function void printif _((char*str,int c)); +Eextern int bin_help _((char*nam,char**argv,char*ops,int func)); Eextern int bin_fc _((char*nam,char**argv,char*ops,int func)); Lstatic int fcgetcomm _((char*s)); Lstatic int fcsubs _((char**sp,struct asgment*sub)); diff -u zsh-4.0.7/Src/hashtable.h zsh-4.0.7-help/Src/hashtable.h --- zsh-4.0.7/Src/hashtable.h 1999-04-15 20:05:38.000000000 +0200 +++ zsh-4.0.7-help/Src/hashtable.h 2003-11-14 13:54:21.000000000 +0100 @@ -56,6 +56,7 @@ #define BIN_ECHO 22 #define BIN_DISABLE 23 #define BIN_ENABLE 24 +#define BIN_HELP 25 /* These currently depend on being 0 and 1. */ #define BIN_SETOPT 0 Common subdirectories: zsh-4.0.7/Src/Modules and zsh-4.0.7-help/Src/Modules Common subdirectories: zsh-4.0.7/Src/Zle and zsh-4.0.7-help/Src/Zle Binary files zsh-4.0.7/Src/zsh and zsh-4.0.7-help/Src/zsh differ