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
use std::error::Error;
use std::fmt;
macro_rules! try_and_report {
($name:expr, $result:expr, $env:ident) => {
match $result {
Ok(val) => val,
Err(e) => {
let err = $crate::spawn::builtin::ErrorWithBuiltinName {
name: $name,
err: e,
};
$env.report_error(&err);
return Ok($crate::future::Async::Ready(EXIT_ERROR.into()));
},
}
}
}
#[macro_use] mod generic;
#[macro_use] mod trivial;
mod cd;
mod colon;
mod echo;
mod false_cmd;
mod pwd;
mod shift;
mod true_cmd;
pub use self::cd::{Cd, cd, CdFuture, SpawnedCd};
pub use self::colon::{Colon, colon, SpawnedColon};
pub use self::echo::{Echo, echo, EchoFuture, SpawnedEcho};
pub use self::false_cmd::{False, false_cmd, SpawnedFalse};
pub use self::pwd::{Pwd, pwd, PwdFuture, SpawnedPwd};
pub use self::shift::{Shift, shift, SpawnedShift};
pub use self::true_cmd::{True, true_cmd, SpawnedTrue};
#[derive(Debug)]
struct ErrorWithBuiltinName<T> {
name: &'static str,
err: T,
}
impl<T: Error> Error for ErrorWithBuiltinName<T> {
fn description(&self) -> &str {
self.err.description()
}
fn cause(&self) -> Option<&Error> {
Some(&self.err)
}
}
impl<T: fmt::Display> fmt::Display for ErrorWithBuiltinName<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{}: {}", self.name, self.err)
}
}