]> git.ipfire.org Git - thirdparty/bash.git/blame - builtins/builtin.def
Imported from ../bash-2.05a.tar.gz.
[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
4Copyright (C) 1987, 1989, 1991 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
bb70624e 10Software Foundation; either version 2, or (at your option) any later
726f6388
JA
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
bb70624e 20Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
726f6388
JA
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
ccc6cda3 31#include <config.h>
726f6388 32
ccc6cda3 33#if defined (HAVE_UNISTD_H)
cce855bc
JA
34# ifdef _MINIX
35# include <sys/types.h>
36# endif
ccc6cda3
JA
37# include <unistd.h>
38#endif
726f6388 39
ccc6cda3 40#include "../shell.h"
726f6388
JA
41#include "common.h"
42
43extern char *this_command_name;
44
45/* Run the command mentioned in list directly, without going through the
46 normal alias/function/builtin/filename lookup process. */
ccc6cda3 47int
726f6388
JA
48builtin_builtin (list)
49 WORD_LIST *list;
50{
f73dda09 51 sh_builtin_func_t *function;
726f6388
JA
52 register char *command;
53
54 if (!list)
55 return (EXECUTION_SUCCESS);
56
57 command = (list->word->word);
58#if defined (DISABLED_BUILTINS)
59 function = builtin_address (command);
60#else /* !DISABLED_BUILTINS */
61 function = find_shell_builtin (command);
62#endif /* !DISABLED_BUILTINS */
63
64 if (!function)
65 {
66 builtin_error ("%s: not a shell builtin", command);
67 return (EXECUTION_FAILURE);
68 }
69 else
70 {
71 this_command_name = command;
72 list = list->next;
73 return ((*function) (list));
74 }
75}