1 This file is help.def, from which is created help.c.
2 It implements the builtin "help" in Bash.
4 Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
6 This file is part of GNU Bash, the Bourne Again SHell.
8 Bash is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 1, or (at your option) any later
13 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License along
19 with Bash; see the file COPYING. If not, write to the Free Software
20 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 $FUNCTION help_builtin
26 $SHORT_DOC help [pattern ...]
27 Display helpful information about builtin commands. If PATTERN is
28 specified, gives detailed help on all commands matching PATTERN,
29 otherwise a list of the builtins is printed.
34 #include "../builtins.h"
36 #if defined (USE_GLOB_LIBRARY)
37 # include <glob/glob.h>
39 # define FNM_NOMATCH 1
40 #endif /* USE_GLOB_LIBRARY */
42 /* Print out a list of the known functions in the shell, and what they do.
43 If LIST is supplied, print out the list which matches for each pattern
53 show_shell_version ();
55 "Shell commands that are defined internally. Type `help' to see this list.\n\
56 Type `help name' to find out more about the function `name'.\n\
57 Use `info bash' to find out more about the shell in general.\n\
59 A star (*) next to a name means that the command is disabled.\n\
62 for (i = 0; i < num_shell_builtins; i++)
65 sprintf (blurb, "%c%s",
66 (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*',
67 shell_builtins[i].short_doc);
75 for (j = strlen (blurb); j < 35; j++)
87 if (glob_pattern_p (list->word->word))
89 printf ("Shell commands matching keyword%s `",
90 list->next ? "s" : "");
91 print_word_list (list, ", ");
97 register int i = 0, plen;
100 pattern = list->word->word;
101 plen = strlen (pattern);
103 while (name = shell_builtins[i].name)
108 if ((strncmp (pattern, name, plen) == 0) ||
109 (fnmatch (pattern, name, 0) != FNM_NOMATCH))
111 printf ("%s: %s\n", name, shell_builtins[i].short_doc);
114 shell_builtins[i].long_doc[doc_index]; doc_index++)
115 printf (" %s\n", shell_builtins[i].long_doc[doc_index]);
126 fprintf (stderr, "No help topics match `%s'. Try `help help'.\n",
129 return (EXECUTION_FAILURE);
133 return (EXECUTION_SUCCESS);