1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// This file is part of yash, an extended POSIX shell.
// Copyright (C) 2023 WATANABE Yuki
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Eval built-in
//!
//! The **`eval`** built-in evaluates the arguments as shell commands.
//!
//! # Synopsis
//!
//! ```sh
//! eval [command…]
//! ```
//!
//! # Description
//!
//! This built-in parses and executes the argument as a shell script in
//! the current shell environment.
//!
//! # Options
//!
//! None.
//!
//! (TODO: non-portable options)
//!
//! # Operands
//!
//! The operand is a command string to be evaluated.
//! If more than one operand is given, they are concatenated with spaces
//! between them to form a single command string.
//!
//! # Errors
//!
//! During parsing and execution, any syntax error or runtime error may
//! occur.
//!
//! # Exit status
//!
//! The exit status of the `eval` built-in is the exit status of the last
//! command executed in the command string.
//! If there is no command in the string, the exit status is zero.
//! In case of a syntax error, the exit status is 2 ([`ExitStatus::ERROR`]).
//!
//! # Portability
//!
//! POSIX does not require the eval built-in to conform to the Utility Syntax
//! Guidelines, which means portable scripts cannot use any options or the `--`
//! separator for the built-in.
use crateResult;
use NonZeroU64;
use ExitStatus;
use Field;
use Env;
use ReadEvalLoop;
use Memory;
use Lexer;
use Source;
/// Entry point of the `eval` built-in execution
pub async
/// Joins the arguments to make a single command string.