Repository: casey/just
File: src/evaluator.rs (Rust)

Code before:
        then,
        otherwise,
        operator,
      } => {
        let lhs_value = self.evaluate_expression(lhs)?;
        let rhs_value = self.evaluate_expression(rhs)?;
        let condition = match operator {
          ConditionalOperator::Equality => lhs_value == rhs_value,
          ConditionalOperator::Inequality => lhs_value != rhs_value,
          ConditionalOperator::RegexMatch => Regex::new(&rhs_value)
            .map_err(|source| Error::RegexCompile { source })?
            .is_match(&lhs_value),
        };
        if condition {
          self.evaluate_expression(then)
        } else {
          self.evaluate_expression(otherwise)
        }
      }
      Expression::Group { contents } => self.evaluate_expression(contents),
      Expression::Join { lhs, rhs } => {
        let lhs = if let Some(lhs) = lhs {
          self.evaluate_expression(lhs)?
        } else {
          String::new()
        };
        Ok(lhs + "/" + &self.evaluate_expression(rhs)?)
      }
    }
  }

  fn run_backtick(&self, raw: &str, token: &Token<'src>) -> RunResult<'src, String> {
    let mut cmd = self.settings.shell_command(self.config);

    cmd.arg(raw);

    cmd.current_dir(&self.search.working_directory);

    cmd.export(self.settings, self.dotenv, &self.scope);

    cmd.stdin(process::Stdio::inherit());

    cmd.stderr(if self.config.verbosity.quiet() {
      process::Stdio::null()
    } else {
      process::Stdio::inherit()
    });

    InterruptHandler::guard(|| {
      output(cmd).map_err(|output_error| Error::Backtick {
        token: *token,

Review comment (suggestion):
Minor, feel free to ignore. You might consider `match` for this one:

```rust
        let lhs = match lhs {
            Some(lhs) => self.evaluate_expression(lhs)?,
            None => String::new(),
        };
```

Code after:
        then,
        otherwise,
        operator,
      } => {
        let lhs_value = self.evaluate_expression(lhs)?;
        let rhs_value = self.evaluate_expression(rhs)?;
        let condition = match operator {
          ConditionalOperator::Equality => lhs_value == rhs_value,
          ConditionalOperator::Inequality => lhs_value != rhs_value,
          ConditionalOperator::RegexMatch => Regex::new(&rhs_value)
            .map_err(|source| Error::RegexCompile { source })?
            .is_match(&lhs_value),
        };
        if condition {
          self.evaluate_expression(then)
        } else {
          self.evaluate_expression(otherwise)
        }
      }
      Expression::Group { contents } => self.evaluate_expression(contents),
      Expression::Join { lhs: None, rhs } => Ok("/".to_string() + &self.evaluate_expression(rhs)?),
      Expression::Join {
        lhs: Some(lhs),
        rhs,
      } => Ok(self.evaluate_expression(lhs)? + "/" + &self.evaluate_expression(rhs)?),
    }
  }

  fn run_backtick(&self, raw: &str, token: &Token<'src>) -> RunResult<'src, String> {
    let mut cmd = self.settings.shell_command(self.config);

    cmd.arg(raw);

    cmd.current_dir(&self.search.working_directory);

    cmd.export(self.settings, self.dotenv, &self.scope);

    cmd.stdin(process::Stdio::inherit());

    cmd.stderr(if self.config.verbosity.quiet() {
      process::Stdio::null()
    } else {
      process::Stdio::inherit()
    });

    InterruptHandler::guard(|| {
      output(cmd).map_err(|output_error| Error::Backtick {
        token: *token,
        output_error,
      })
    })