blob: 5e824c92d28585fe6d924af772cf06b3294df0d3 [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001This file is eval.def, from which is created eval.c.
2It implements the builtin "eval" in Bash.
3
Jari Aalto31859422009-01-12 13:36:28 +00004Copyright (C) 1987-2009 Free Software Foundation, Inc.
Jari Aalto726f6381996-08-26 18:22:31 +00005
6This file is part of GNU Bash, the Bourne Again SHell.
7
Jari Aalto31859422009-01-12 13:36:28 +00008Bash 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.
Jari Aalto726f6381996-08-26 18:22:31 +000012
Jari Aalto31859422009-01-12 13:36:28 +000013Bash 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.
Jari Aalto726f6381996-08-26 18:22:31 +000017
Jari Aalto31859422009-01-12 13:36:28 +000018You should have received a copy of the GNU General Public License
19along with Bash. If not, see <http://www.gnu.org/licenses/>.
Jari Aalto726f6381996-08-26 18:22:31 +000020
21$PRODUCES eval.c
22
23$BUILTIN eval
24$FUNCTION eval_builtin
25$SHORT_DOC eval [arg ...]
Jari Aalto31859422009-01-12 13:36:28 +000026Execute arguments as a shell command.
27
28Combine ARGs into a single string, use the result as input to the shell,
29and execute the resulting commands.
30
31Exit Status:
32Returns exit status of command or success if command is null.
Jari Aalto726f6381996-08-26 18:22:31 +000033$END
34
Jari Aaltoccc6cda1996-12-23 17:02:34 +000035#include <config.h>
36#if defined (HAVE_UNISTD_H)
Jari Aaltocce855b1998-04-17 19:52:44 +000037# ifdef _MINIX
38# include <sys/types.h>
39# endif
40# include <unistd.h>
Jari Aaltoccc6cda1996-12-23 17:02:34 +000041#endif
42
Jari Aalto726f6381996-08-26 18:22:31 +000043#include "../shell.h"
Jari Aaltoccc6cda1996-12-23 17:02:34 +000044#include "bashgetopt.h"
Jari Aaltod166f041997-06-05 14:59:13 +000045#include "common.h"
Jari Aalto726f6381996-08-26 18:22:31 +000046
47/* Parse the string that these words make, and execute the command found. */
48int
49eval_builtin (list)
50 WORD_LIST *list;
51{
Jari Aaltoccc6cda1996-12-23 17:02:34 +000052 if (no_options (list))
53 return (EX_USAGE);
Jari Aalto7117c2d2002-07-17 14:10:11 +000054 list = loptend; /* skip over possible `--' */
Jari Aalto726f6381996-08-26 18:22:31 +000055
Chet Rameyac50fba2014-02-26 09:36:43 -050056 return (list ? evalstring (string_list (list), "eval", SEVAL_NOHIST) : EXECUTION_SUCCESS);
Jari Aalto726f6381996-08-26 18:22:31 +000057}