Line data Source code
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-2009 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 9 : it under the terms of the GNU General Public License as published by 10 : the Free Software Foundation, either version 3 of the License, or 11 : (at your option) any later version. 12 : 13 : Bash is distributed in the hope that it will be useful, 14 : but WITHOUT ANY WARRANTY; without even the implied warranty of 15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 : GNU General Public License for more details. 17 : 18 : You should have received a copy of the GNU General Public License 19 : along with Bash. If not, see <http://www.gnu.org/licenses/>. 20 : 21 : $PRODUCES builtin.c 22 : 23 : $BUILTIN builtin 24 : $FUNCTION builtin_builtin 25 : $SHORT_DOC builtin [shell-builtin [arg ...]] 26 : Execute shell builtins. 27 : 28 : Execute SHELL-BUILTIN with arguments ARGs without performing command 29 : lookup. This is useful when you wish to reimplement a shell builtin 30 : as a shell function, but need to execute the builtin within the function. 31 : 32 : Exit Status: 33 : Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is 34 : not a shell builtin.. 35 : $END 36 : #include <config.h> 37 : 38 : #if defined (HAVE_UNISTD_H) 39 : # ifdef _MINIX 40 : # include <sys/types.h> 41 : # endif 42 : # include <unistd.h> 43 : #endif 44 : 45 : #include "../shell.h" 46 : #include "common.h" 47 : #include "bashgetopt.h" 48 : 49 : extern 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. */ 53 : int 54 76 : builtin_builtin (list) 55 : WORD_LIST *list; 56 : { 57 76 : sh_builtin_func_t *function; 58 76 : register char *command; 59 : 60 76 : if (no_options (list)) 61 : return (EX_USAGE); 62 76 : list = loptend; /* skip over possible `--' */ 63 : 64 76 : if (list == 0) 65 : return (EXECUTION_SUCCESS); 66 : 67 25 : command = list->word->word; 68 : #if defined (DISABLED_BUILTINS) 69 : function = builtin_address (command); 70 : #else /* !DISABLED_BUILTINS */ 71 25 : function = find_shell_builtin (command); 72 : #endif /* !DISABLED_BUILTINS */ 73 : 74 25 : if (!function) 75 : { 76 14 : sh_notbuiltin (command); 77 14 : return (EXECUTION_FAILURE); 78 : } 79 : else 80 : { 81 11 : this_command_name = command; 82 11 : list = list->next; 83 11 : return ((*function) (list)); 84 : } 85 : }