source: vendor/bash/3.1/builtins/builtin.def

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 2.1 KB
Line 
1This file is builtin.def, from which is created builtin.c.
2It implements the builtin "builtin" in Bash.
3
4Copyright (C) 1987-2002 Free Software Foundation, Inc.
5
6This file is part of GNU Bash, the Bourne Again SHell.
7
8Bash is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 2, or (at your option) any later
11version.
12
13Bash is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License along
19with Bash; see the file COPYING. If not, write to the Free Software
20Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
21
22$PRODUCES builtin.c
23
24$BUILTIN builtin
25$FUNCTION builtin_builtin
26$SHORT_DOC builtin [shell-builtin [arg ...]]
27Run a shell builtin. This is useful when you wish to rename a
28shell builtin to be a function, but need the functionality of the
29builtin within the function itself.
30$END
31#include <config.h>
32
33#if defined (HAVE_UNISTD_H)
34# ifdef _MINIX
35# include <sys/types.h>
36# endif
37# include <unistd.h>
38#endif
39
40#include "../shell.h"
41#include "common.h"
42#include "bashgetopt.h"
43
44extern char *this_command_name;
45
46/* Run the command mentioned in list directly, without going through the
47 normal alias/function/builtin/filename lookup process. */
48int
49builtin_builtin (list)
50 WORD_LIST *list;
51{
52 sh_builtin_func_t *function;
53 register char *command;
54
55 if (no_options (list))
56 return (EX_USAGE);
57 list = loptend; /* skip over possible `--' */
58
59 if (list == 0)
60 return (EXECUTION_SUCCESS);
61
62 command = list->word->word;
63#if defined (DISABLED_BUILTINS)
64 function = builtin_address (command);
65#else /* !DISABLED_BUILTINS */
66 function = find_shell_builtin (command);
67#endif /* !DISABLED_BUILTINS */
68
69 if (!function)
70 {
71 sh_notbuiltin (command);
72 return (EXECUTION_FAILURE);
73 }
74 else
75 {
76 this_command_name = command;
77 list = list->next;
78 return ((*function) (list));
79 }
80}
Note: See TracBrowser for help on using the repository browser.