]> git.ipfire.org Git - thirdparty/bash.git/blame - builtins/builtin.def
Bash-4.3 patch 1
[thirdparty/bash.git] / builtins / builtin.def
CommitLineData
726f6388
JA
1This file is builtin.def, from which is created builtin.c.
2It implements the builtin "builtin" in Bash.
3
3185942a 4Copyright (C) 1987-2009 Free Software Foundation, Inc.
726f6388
JA
5
6This file is part of GNU Bash, the Bourne Again SHell.
7
3185942a
JA
8Bash is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 3 of the License, or
11(at your option) any later version.
726f6388 12
3185942a
JA
13Bash is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
726f6388 17
3185942a
JA
18You should have received a copy of the GNU General Public License
19along with Bash. If not, see <http://www.gnu.org/licenses/>.
726f6388
JA
20
21$PRODUCES builtin.c
22
23$BUILTIN builtin
24$FUNCTION builtin_builtin
25$SHORT_DOC builtin [shell-builtin [arg ...]]
3185942a
JA
26Execute shell builtins.
27
28Execute SHELL-BUILTIN with arguments ARGs without performing command
29lookup. This is useful when you wish to reimplement a shell builtin
30as a shell function, but need to execute the builtin within the function.
31
32Exit Status:
33Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is
34not a shell builtin..
726f6388 35$END
ccc6cda3 36#include <config.h>
726f6388 37
ccc6cda3 38#if defined (HAVE_UNISTD_H)
cce855bc
JA
39# ifdef _MINIX
40# include <sys/types.h>
41# endif
ccc6cda3
JA
42# include <unistd.h>
43#endif
726f6388 44
ccc6cda3 45#include "../shell.h"
726f6388 46#include "common.h"
7117c2d2 47#include "bashgetopt.h"
726f6388
JA
48
49extern char *this_command_name;
50
51/* Run the command mentioned in list directly, without going through the
52 normal alias/function/builtin/filename lookup process. */
ccc6cda3 53int
726f6388
JA
54builtin_builtin (list)
55 WORD_LIST *list;
56{
f73dda09 57 sh_builtin_func_t *function;
726f6388
JA
58 register char *command;
59
7117c2d2
JA
60 if (no_options (list))
61 return (EX_USAGE);
62 list = loptend; /* skip over possible `--' */
63
64 if (list == 0)
726f6388
JA
65 return (EXECUTION_SUCCESS);
66
7117c2d2 67 command = list->word->word;
726f6388
JA
68#if defined (DISABLED_BUILTINS)
69 function = builtin_address (command);
70#else /* !DISABLED_BUILTINS */
71 function = find_shell_builtin (command);
72#endif /* !DISABLED_BUILTINS */
73
74 if (!function)
75 {
b80f6443 76 sh_notbuiltin (command);
726f6388
JA
77 return (EXECUTION_FAILURE);
78 }
79 else
80 {
81 this_command_name = command;
82 list = list->next;
83 return ((*function) (list));
84 }
85}