Imported from ../bash-1.14.7.tar.gz.
[platform/upstream/bash.git] / builtins / builtin.def
1 This file is builtin.def, from which is created builtin.c.
2 It implements the builtin "builtin" in Bash.
3
4 Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
5
6 This file is part of GNU Bash, the Bourne Again SHell.
7
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
11 version.
12
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
16 for more details.
17
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.
21
22 $PRODUCES builtin.c
23
24 $BUILTIN builtin
25 $FUNCTION builtin_builtin
26 $SHORT_DOC builtin [shell-builtin [arg ...]]
27 Run a shell builtin.  This is useful when you wish to rename a
28 shell builtin to be a function, but need the functionality of the
29 builtin within the function itself.
30 $END
31
32 #include "../shell.h"
33
34 #include "common.h"
35
36 extern char *this_command_name;
37
38 /* Run the command mentioned in list directly, without going through the
39    normal alias/function/builtin/filename lookup process. */
40 builtin_builtin (list)
41      WORD_LIST *list;
42 {
43   Function *function;
44   register char *command;
45
46   if (!list)
47     return (EXECUTION_SUCCESS);
48
49   command = (list->word->word);
50 #if defined (DISABLED_BUILTINS)
51   function = builtin_address (command);
52 #else /* !DISABLED_BUILTINS */
53   function = find_shell_builtin (command);
54 #endif /* !DISABLED_BUILTINS */
55
56   if (!function)
57     {
58       builtin_error ("%s: not a shell builtin", command);
59       return (EXECUTION_FAILURE);
60     }
61   else
62     {
63       this_command_name = command;
64       list = list->next;
65       return ((*function) (list));
66     }
67 }