Skip to content

Commit 365ddc7

Browse files
committed
format
1 parent f89e867 commit 365ddc7

File tree

6 files changed

+67
-60
lines changed

6 files changed

+67
-60
lines changed

src/parser.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,10 @@ fn parse_unquoted_word(input: &str) -> ParseResult<Vec<WordPart>> {
652652
.ok()
653653
.map(|(_, parts)| {
654654
if parts.len() == 1
655-
&& let WordPart::Text(text) = &parts[0] {
656-
return !is_reserved_word(text);
657-
}
655+
&& let WordPart::Text(text) = &parts[0]
656+
{
657+
return !is_reserved_word(text);
658+
}
658659
true
659660
})
660661
.unwrap_or(true)
@@ -1042,10 +1043,10 @@ fn assert_whitespace_or_end_and_skip(input: &str) -> ParseResult<()> {
10421043
fn assert_whitespace_or_end(input: &str) -> ParseResult<()> {
10431044
if let Some(next_char) = input.chars().next()
10441045
&& !next_char.is_whitespace()
1045-
&& !matches!(next_char, ';' | '&' | '|' | '(' | ')')
1046-
{
1047-
return Err(ParseError::Failure(fail_for_trailing_input(input)));
1048-
}
1046+
&& !matches!(next_char, ';' | '&' | '|' | '(' | ')')
1047+
{
1048+
return Err(ParseError::Failure(fail_for_trailing_input(input)));
1049+
}
10491050
Ok((input, ()))
10501051
}
10511052

src/shell/child_process_tracker.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ impl ChildProcessTracker {
4040

4141
pub fn track(&self, child: &Child) {
4242
if let Err(err) = self.0.track(child)
43-
&& cfg!(debug_assertions) && child.id().is_some() {
44-
panic!("Could not track process: {:#}", err);
45-
}
43+
&& cfg!(debug_assertions)
44+
&& child.id().is_some()
45+
{
46+
panic!("Could not track process: {:#}", err);
47+
}
4648
}
4749
}
4850

src/shell/command.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,29 @@ async fn resolve_command<'a>(
128128
if Path::new(&command_name.name).components().count() > 1
129129
&& let Some(shebang) = resolve_shebang(&command_path).map_err(|err| {
130130
ResolveCommandError::FailedShebang(FailedShebangError::Any(err.into()))
131-
})? {
132-
let (shebang_command_name, mut args) = if shebang.string_split {
133-
let mut args = parse_shebang_args(&shebang.command, context)
134-
.await
135-
.map_err(FailedShebangError::Any)?;
136-
args.push(command_path.clone().into_os_string());
137-
(args.remove(0), args)
138-
} else {
139-
(
140-
shebang.command.into(),
141-
vec![command_path.clone().into_os_string()],
142-
)
143-
};
144-
args.extend(original_args.iter().cloned());
145-
return Ok(ResolvedCommand {
146-
command_name: CommandName::Unresolved(UnresolvedCommandName {
147-
name: shebang_command_name,
148-
base_dir: command_path.parent().unwrap().to_path_buf(),
149-
}),
150-
args: Cow::Owned(args),
151-
});
152-
}
131+
})?
132+
{
133+
let (shebang_command_name, mut args) = if shebang.string_split {
134+
let mut args = parse_shebang_args(&shebang.command, context)
135+
.await
136+
.map_err(FailedShebangError::Any)?;
137+
args.push(command_path.clone().into_os_string());
138+
(args.remove(0), args)
139+
} else {
140+
(
141+
shebang.command.into(),
142+
vec![command_path.clone().into_os_string()],
143+
)
144+
};
145+
args.extend(original_args.iter().cloned());
146+
return Ok(ResolvedCommand {
147+
command_name: CommandName::Unresolved(UnresolvedCommandName {
148+
name: shebang_command_name,
149+
base_dir: command_path.parent().unwrap().to_path_buf(),
150+
}),
151+
args: Cow::Owned(args),
152+
});
153+
}
153154

154155
Ok(ResolvedCommand {
155156
command_name: CommandName::Resolved(command_path),

src/shell/commands/rm.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ async fn execute_remove(cwd: &Path, args: &[OsString]) -> Result<()> {
6363
remove_file_or_dir(&path, &flags).await
6464
};
6565
if let Err(err) = result
66-
&& (err.kind() != ErrorKind::NotFound || !flags.force) {
67-
bail!(
68-
"cannot remove '{}': {}",
69-
specified_path.to_string_lossy(),
70-
err
71-
);
72-
}
66+
&& (err.kind() != ErrorKind::NotFound || !flags.force)
67+
{
68+
bail!(
69+
"cannot remove '{}': {}",
70+
specified_path.to_string_lossy(),
71+
err
72+
);
73+
}
7374
}
7475

7576
Ok(())

src/shell/commands/xargs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ fn xargs_collect_args(
6767

6868
// remove last arg if it is empty
6969
if let Some(last) = args.last()
70-
&& last.is_empty() {
71-
args.pop();
72-
}
70+
&& last.is_empty()
71+
{
72+
args.pop();
73+
}
7374
} else {
7475
args.extend(delimit_blanks(&text)?);
7576
}

src/shell/types.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ impl ShellState {
154154
&& let Ok(cwd) = deno_path_util::fs::canonicalize_path_maybe_not_exists(
155155
&sys_traits::impls::RealSys,
156156
cwd,
157-
) {
158-
// this will update the environment variable too
159-
self.set_cwd(cwd);
160-
}
157+
)
158+
{
159+
// this will update the environment variable too
160+
self.set_cwd(cwd);
161+
}
161162
} else {
162163
self.shell_vars.remove(&name);
163164
self.env_vars.insert(name, value.to_os_string());
@@ -268,24 +269,24 @@ impl ShellPipeReader {
268269
pub fn stdin() -> ShellPipeReader {
269270
#[cfg(unix)]
270271
pub fn dup_stdin_as_pipe_reader() -> std::io::PipeReader {
271-
use std::os::fd::AsFd;
272-
use std::os::fd::IntoRawFd;
273-
use std::os::fd::FromRawFd;
274-
let owned = std::io::stdin().as_fd().try_clone_to_owned().unwrap();
275-
let raw = owned.into_raw_fd(); // transfer ownership
276-
// SAFETY: `raw` is a fresh, owned fd; PipeReader will close it.
277-
unsafe { std::io::PipeReader::from_raw_fd(raw) }
272+
use std::os::fd::AsFd;
273+
use std::os::fd::FromRawFd;
274+
use std::os::fd::IntoRawFd;
275+
let owned = std::io::stdin().as_fd().try_clone_to_owned().unwrap();
276+
let raw = owned.into_raw_fd();
277+
// SAFETY: `raw` is a fresh, owned fd; PipeReader will close it.
278+
unsafe { std::io::PipeReader::from_raw_fd(raw) }
278279
}
279280

280281
#[cfg(windows)]
281282
pub fn dup_stdin_as_pipe_reader() -> io::Result<PipeReader> {
282-
use std::os::windows::io::AsHandle;
283-
use std::os::windows::io::IntoRawHandle;
284-
use std::os::windows::io::FromRawHandle;
285-
let owned = io::stdin().as_handle().try_clone_to_owned().unwrap();
286-
let raw = owned.into_raw_handle(); // transfer ownership
287-
// SAFETY: `raw` is a fresh, owned HANDLE; PipeReader will close it.
288-
unsafe { std::io::PipeReader::from_raw_handle(raw) }
283+
use std::os::windows::io::AsHandle;
284+
use std::os::windows::io::FromRawHandle;
285+
use std::os::windows::io::IntoRawHandle;
286+
let owned = io::stdin().as_handle().try_clone_to_owned().unwrap();
287+
let raw = owned.into_raw_handle();
288+
// SAFETY: `raw` is a fresh, owned HANDLE; PipeReader will close it.
289+
unsafe { std::io::PipeReader::from_raw_handle(raw) }
289290
}
290291

291292
ShellPipeReader::OsPipe(dup_stdin_as_pipe_reader())

0 commit comments

Comments
 (0)