Merge nucleic/tidy-thistle-egret-5vjm into dev
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use brush_core::builtins;
|
||||
use clap::Parser;
|
||||
@@ -22,13 +22,29 @@ impl builtins::Command for DotCommand {
|
||||
context: brush_core::ExecutionContext<'_, SE>,
|
||||
) -> Result<brush_core::ExecutionResult, Self::Error> {
|
||||
// TODO(dot): Handle trap inheritance.
|
||||
// nash: POSIX requires `.` to search PATH when its operand has no slash.
|
||||
// Git's `git-subtree` relies on this with `. git-sh-setup`; treating the
|
||||
// operand as cwd-relative leaves `require_work_tree` undefined.
|
||||
let script_path = Path::new(&self.script_path);
|
||||
let resolved_path = if context.shell.options().source_builtin_searches_path
|
||||
&& !self.script_path.chars().any(std::path::is_separator)
|
||||
{
|
||||
context
|
||||
.shell
|
||||
.env_str("PATH")
|
||||
.and_then(|path| {
|
||||
std::env::split_paths(path.as_ref())
|
||||
.map(|dir| dir.join(script_path))
|
||||
.find(|candidate| candidate.is_file())
|
||||
})
|
||||
.unwrap_or_else(|| PathBuf::from(script_path))
|
||||
} else {
|
||||
PathBuf::from(script_path)
|
||||
};
|
||||
|
||||
context
|
||||
.shell
|
||||
.source_script(
|
||||
Path::new(&self.script_path),
|
||||
self.script_args.iter(),
|
||||
&context.params,
|
||||
)
|
||||
.source_script(&resolved_path, self.script_args.iter(), &context.params)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user