Skip to content

Commit 22b593d

Browse files
authored
Merge branch 'master' into update-deps
2 parents 2b2e973 + f1be6b8 commit 22b593d

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Vagrant.configure("2") do |config|
99

1010
# Install the dependencies needed for exa to build.
1111
config.vm.provision :shell, privileged: true, inline:
12-
%[apt-get install -y git cmake libgit2-dev libssh2-1-dev curl attr]
12+
%[apt-get install -y git cmake libgit2-dev libssh2-1-dev curl attr pkg-config]
1313

1414
# Guarantee that the timezone is UTC -- some of the tests
1515
# depend on this (for now).

src/bin/main.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ fn main() {
1010
let mut stdout = stdout();
1111

1212
match Exa::new(&args, &mut stdout) {
13-
Ok(mut exa) => if let Err(e) = exa.run() {
14-
match e.kind() {
15-
ErrorKind::BrokenPipe => exit(0),
16-
_ => {
17-
writeln!(stderr(), "{}", e).unwrap();
18-
exit(1);
19-
},
13+
Ok(mut exa) => {
14+
match exa.run() {
15+
Ok(exit_status) => exit(exit_status),
16+
Err(e) => {
17+
match e.kind() {
18+
ErrorKind::BrokenPipe => exit(0),
19+
_ => {
20+
writeln!(stderr(), "{}", e).unwrap();
21+
exit(1);
22+
},
23+
};
24+
}
2025
};
2126
},
2227
Err(e) => {

src/exa.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ impl<'w, W: Write + 'w> Exa<'w, W> {
6060
})
6161
}
6262

63-
pub fn run(&mut self) -> IOResult<()> {
63+
pub fn run(&mut self) -> IOResult<i32> {
6464
let mut files = Vec::new();
6565
let mut dirs = Vec::new();
66+
let mut exit_status = 0;
6667

6768
// List the current directory by default, like ls.
6869
if self.args.is_empty() {
@@ -72,6 +73,7 @@ impl<'w, W: Write + 'w> Exa<'w, W> {
7273
for file_name in self.args.iter() {
7374
match File::from_path(Path::new(&file_name), None) {
7475
Err(e) => {
76+
exit_status = 2;
7577
writeln!(stderr(), "{}: {}", file_name, e)?;
7678
},
7779
Ok(f) => {
@@ -98,10 +100,10 @@ impl<'w, W: Write + 'w> Exa<'w, W> {
98100
self.options.filter.filter_argument_files(&mut files);
99101
self.print_files(None, files)?;
100102

101-
self.print_dirs(dirs, no_files, is_only_dir)
103+
self.print_dirs(dirs, no_files, is_only_dir, exit_status)
102104
}
103105

104-
fn print_dirs(&mut self, dir_files: Vec<Dir>, mut first: bool, is_only_dir: bool) -> IOResult<()> {
106+
fn print_dirs(&mut self, dir_files: Vec<Dir>, mut first: bool, is_only_dir: bool, exit_status: i32) -> IOResult<i32> {
105107
for dir in dir_files {
106108

107109
// Put a gap between directories, or between the list of files and
@@ -141,15 +143,18 @@ impl<'w, W: Write + 'w> Exa<'w, W> {
141143
}
142144

143145
self.print_files(Some(&dir), children)?;
144-
self.print_dirs(child_dirs, false, false)?;
146+
match self.print_dirs(child_dirs, false, false, exit_status) {
147+
Ok(_) => (),
148+
Err(e) => return Err(e),
149+
}
145150
continue;
146151
}
147152
}
148153

149154
self.print_files(Some(&dir), children)?;
150155
}
151156

152-
Ok(())
157+
Ok(exit_status)
153158
}
154159

155160
/// Prints the list of files using whichever view is selected.

0 commit comments

Comments
 (0)