Skip to content

Commit

Permalink
man: added local search mode
Browse files Browse the repository at this point in the history
  • Loading branch information
veremenko-y committed Oct 17, 2024
1 parent fba1b32 commit fa0daa2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Applications/util/man.1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
man \- display on-line reference manuals
.SH SYNOPSIS
.B man
[\-w] [\-b|\-q] [section-number] page
[\-w] [\-v|\-q] [\-l file] [section-number] page
.SH DESCRIPTION
This document describes the FUZIX version of
.BR man .
Expand Down Expand Up @@ -57,6 +57,9 @@ Force verbose output. (default)
.TP
.I "-q"
Force quiet output.
.TP
.I "-l"
Search pages in current directory. Manual section is ignored.
.SH EXAMPLES
.IP
man ls
Expand Down
17 changes: 17 additions & 0 deletions Applications/util/man.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ char man_file[256] = "";

int flg_w = 0;
int verbose = 1;
int local = 0;


/* Prototypes */
Expand Down Expand Up @@ -106,6 +107,19 @@ int find_page(char *name, char *sect)
char *mc, *mp, *ms, *su, *nmc, *nmp, *nms, *nsu;
int rv = -1;

if (local) {
if ((rv = open_page(name)) < 0) {
fprintf(stderr, "File not found: %s\n", name);
exit(1);
}
if (flg_w) {
printf("%s\n", name);
close(rv);
return 0;
}
return rv;
}

manpath = getenv("MANPATH");
if (!manpath)
manpath = defpath;
Expand Down Expand Up @@ -1065,6 +1079,9 @@ int main(int argc, char **argv)
case 'q':
verbose = 0;
break;
case 'l':
local = 1;
break;
}
} else if (isdigit(argv[ar][0]))
mansect = argv[ar];
Expand Down

0 comments on commit fa0daa2

Please sign in to comment.