shell: fix script discovery
This commit is contained in:
parent
c35a61fb7f
commit
be3e72b80e
@ -11,6 +11,7 @@
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{self, stdin, stdout, BufRead, BufReader, Write},
|
||||
path::Path,
|
||||
process::ExitCode,
|
||||
};
|
||||
|
||||
@ -126,10 +127,22 @@ fn run(mut input: ShellInput, env: &Env) -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
fn open_script<P: AsRef<Path>>(arg: P) -> io::Result<File> {
|
||||
#[cfg(any(target_os = "yggdrasil", rust_analyzer))]
|
||||
{
|
||||
let from_auxv = std::os::yggdrasil::real_binary_path();
|
||||
if from_auxv.exists() {
|
||||
return File::open(from_auxv);
|
||||
}
|
||||
}
|
||||
|
||||
File::open(arg)
|
||||
}
|
||||
|
||||
fn run_wrapper(args: ShellArgs, env: &Env) -> Result<(), Error> {
|
||||
match args.script {
|
||||
Some(script) => {
|
||||
let script = BufReader::new(File::open(script)?);
|
||||
let script = BufReader::new(open_script(&script)?);
|
||||
run(ShellInput::File(script), env)
|
||||
}
|
||||
None => run(ShellInput::Interactive, env),
|
||||
|
Loading…
x
Reference in New Issue
Block a user