Skip to content

Commit

Permalink
fix: clippy lints please
Browse files Browse the repository at this point in the history
  • Loading branch information
39555 committed Oct 13, 2024
1 parent ef8094c commit d36894f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions brush-core/src/builtins/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub(crate) struct EchoCommand {
}

impl builtins::Command for EchoCommand {
/// Override the default [builtins::Command::new] function to handle clap's limitation related
/// to `--`. See [crate::builtins::parse_known] for more information
/// Override the default [`builtins::Command::new`] function to handle clap's limitation related
/// to `--`. See [`builtins::parse_known`] for more information
/// TODO: we can safely remove this after the issue is resolved
fn new<I>(args: I) -> Result<Self, clap::Error>
where
Expand Down Expand Up @@ -74,6 +74,6 @@ impl builtins::Command for EchoCommand {
write!(context.stdout(), "{s}")?;
context.stdout().flush()?;

return Ok(builtins::ExitCode::Success);
Ok(builtins::ExitCode::Success)
}
}
2 changes: 1 addition & 1 deletion brush-core/src/builtins/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl builtins::Command for KillCommand {
}

if self.list_signals {
return error::unimp("kill -l");
error::unimp("kill -l")
} else {
if self.args.len() != 1 {
writeln!(context.stderr(), "{}: invalid usage", context.command_name)?;
Expand Down
2 changes: 1 addition & 1 deletion brush-core/src/builtins/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl builtins::Command for PrintfCommand {
context.stdout().flush()?;
}

return Ok(builtins::ExitCode::Success);
Ok(builtins::ExitCode::Success)
}
}

Expand Down
6 changes: 4 additions & 2 deletions brush-core/src/builtins/umask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ cfg_if! {
status.umask.ok_or_else(|| error::Error::InvalidUmask)
}
} else {
#[allow(clippy::unnecessary_wraps)]
fn get_umask() -> Result<u32, error::Error> {
let u = nix::sys::stat::umask(Mode::empty());
nix::sys::stat::umask(u);
Ok(u.bits() as u32)
Ok(u32::from(u.bits()))
}
}
}

fn set_umask(value: u32) -> Result<(), error::Error> {
let mode =
nix::sys::stat::Mode::from_bits(value as _).ok_or_else(|| error::Error::InvalidUmask)?;
nix::sys::stat::Mode::from_bits(value.try_into().map_err(|_| error::Error::InvalidUmask)?)
.ok_or_else(|| error::Error::InvalidUmask)?;
nix::sys::stat::umask(mode);
Ok(())
}
Expand Down
22 changes: 9 additions & 13 deletions brush-core/src/interp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,19 +1048,15 @@ async fn expand_assignment_value(
ast::AssignmentValue::Array(arr) => {
let mut expanded_values = vec![];
for (key, value) in arr {
match key {
Some(k) => {
let expanded_key = expansion::basic_expand_word(shell, k).await?.into();
let expanded_value =
expansion::basic_expand_word(shell, value).await?.into();
expanded_values.push((Some(expanded_key), expanded_value));
}
None => {
let split_expanded_value =
expansion::full_expand_and_split_word(shell, value).await?;
for expanded_value in split_expanded_value {
expanded_values.push((None, expanded_value.into()));
}
if let Some(k) = key {
let expanded_key = expansion::basic_expand_word(shell, k).await?.into();
let expanded_value = expansion::basic_expand_word(shell, value).await?.into();
expanded_values.push((Some(expanded_key), expanded_value));
} else {
let split_expanded_value =
expansion::full_expand_and_split_word(shell, value).await?;
for expanded_value in split_expanded_value {
expanded_values.push((None, expanded_value.into()));
}
}
}
Expand Down

0 comments on commit d36894f

Please sign in to comment.