mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-01 05:11:09 +00:00
Fix unix bugs
This commit is contained in:
parent
3fe79a7fab
commit
9db951d5ac
1 changed files with 5 additions and 5 deletions
|
@ -24,7 +24,7 @@ pub fn which_python() -> String {
|
||||||
pub fn detect_magic_number() -> u32 {
|
pub fn detect_magic_number() -> u32 {
|
||||||
let command = if cfg!(windows) { "cmd" } else { "sh" };
|
let command = if cfg!(windows) { "cmd" } else { "sh" };
|
||||||
let arg = if cfg!(windows) { "/C" } else { "-c" };
|
let arg = if cfg!(windows) { "/C" } else { "-c" };
|
||||||
let python_command = format!("\"{} -c 'import importlib.util as util;print(util.MAGIC_NUMBER.hex())'\"", which_python());
|
let python_command = format!("{} -c 'import importlib.util as util;print(util.MAGIC_NUMBER.hex())'", which_python());
|
||||||
let out = Command::new(command)
|
let out = Command::new(command)
|
||||||
.arg(arg)
|
.arg(arg)
|
||||||
.arg(python_command)
|
.arg(python_command)
|
||||||
|
@ -40,10 +40,10 @@ pub fn exec_pyc<S: Into<String>>(file: S) {
|
||||||
// executes over a shell, cause `python` may not exist as an executable file (like pyenv)
|
// executes over a shell, cause `python` may not exist as an executable file (like pyenv)
|
||||||
let command = if cfg!(windows) { "cmd" } else { "sh" };
|
let command = if cfg!(windows) { "cmd" } else { "sh" };
|
||||||
let arg = if cfg!(windows) { "/C" } else { "-c" };
|
let arg = if cfg!(windows) { "/C" } else { "-c" };
|
||||||
|
let python_command = format!("{} {}", which_python(), file.into());
|
||||||
let mut out = Command::new(command)
|
let mut out = Command::new(command)
|
||||||
.arg(arg)
|
.arg(arg)
|
||||||
.arg(which_python())
|
.arg(python_command)
|
||||||
.arg(&file.into())
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("python not found");
|
.expect("python not found");
|
||||||
out.wait().expect("python doesn't work");
|
out.wait().expect("python doesn't work");
|
||||||
|
@ -53,10 +53,10 @@ pub fn eval_pyc<S: Into<String>>(file: S) -> String {
|
||||||
// executes over a shell, cause `python` may not exist as an executable file (like pyenv)
|
// executes over a shell, cause `python` may not exist as an executable file (like pyenv)
|
||||||
let command = if cfg!(windows) { "cmd" } else { "sh" };
|
let command = if cfg!(windows) { "cmd" } else { "sh" };
|
||||||
let arg = if cfg!(windows) { "/C" } else { "-c" };
|
let arg = if cfg!(windows) { "/C" } else { "-c" };
|
||||||
|
let python_command = format!("{} {}", which_python(), file.into());
|
||||||
let out = Command::new(command)
|
let out = Command::new(command)
|
||||||
.arg(arg)
|
.arg(arg)
|
||||||
.arg(which_python())
|
.arg(python_command)
|
||||||
.arg(&file.into())
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("python not found");
|
.expect("python not found");
|
||||||
let out = out.wait_with_output().expect("python doesn't work");
|
let out = out.wait_with_output().expect("python doesn't work");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue