Skip to content

Commit

Permalink
Handle expansion error
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Aug 25, 2021
1 parent b536888 commit feb591b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 3 additions & 7 deletions yash-semantics/src/function_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

//! Implementations of function definition semantics.

use super::Command;
use crate::expansion::expand_word;
use crate::expansion::Field;
use crate::Command;
use crate::Handle;
use async_trait::async_trait;
use std::rc::Rc;
use yash_env::exec::ExitStatus;
Expand All @@ -36,12 +37,7 @@ impl Command for syntax::FunctionDefinition {
origin,
} = match expand_word(env, &self.name).await {
Ok(field) => field,
Err(error) => {
env.print_error(&format_args!("expansion failure: {:?}", error))
.await;
// TODO Handle errors that may happen in expansion
return Ok(());
}
Err(error) => return env.handle(error).await,
};

if let Some(function) = env.functions.get(name.as_str()) {
Expand Down
10 changes: 3 additions & 7 deletions yash-semantics/src/simple_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

//! Implementation of simple command semantics.

use super::Command;
use crate::command_search::search;
use crate::command_search::Target::{Builtin, External, Function};
use crate::expansion::expand_words;
use crate::Command;
use crate::Handle;
use async_trait::async_trait;
use nix::errno::Errno;
use std::ffi::CString;
Expand Down Expand Up @@ -50,12 +51,7 @@ impl Command for syntax::SimpleCommand {
async fn execute(&self, env: &mut Env) -> Result {
let fields = match expand_words(env, &self.words).await {
Ok(fields) => fields,
Err(error) => {
env.print_error(&format_args!("expansion failure: {:?}", error))
.await;
// TODO Handle errors that may happen in expansion
return Ok(());
}
Err(error) => return env.handle(error).await,
};

// TODO open redirections
Expand Down

0 comments on commit feb591b

Please sign in to comment.