Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The phenomenon seems incorrect after setting ScriptOptions -> working_directory. #25

Open
qq253498229 opened this issue Jul 18, 2024 · 1 comment
Assignees

Comments

@qq253498229
Copy link

qq253498229 commented Jul 18, 2024

Describe The Bug

stdout and stderr output different results simultaneously, and stderr seems to be correct.

PS: test_folder folder is not exists

To Reproduce

Error Stack

code:0
out:
/Users/wangbin/src/rust/demo-shell

err:
/var/folders/rl/n9gh_59x6yd2ht485vlrvbtc0000gn/T/fsio_vQFZEgtdBD.sh: line 1: cd: /Users/wangbin/src/rust/demo-shell/test_folder: No such file or directory

Code Sample

use std::env;
use std::path::PathBuf;

use run_script::ScriptOptions;

fn main() {
    let command = "pwd";
    let args = vec![];
    let mut options = ScriptOptions::new();
    options.working_directory = Some(get_test_folder());
    let (code, out, err) = run_script::run(command, &args, &options).unwrap();
    println!("code:{code}");
    println!("out:\n{out}");
    println!("err:\n{err}");
}

fn get_test_folder() -> PathBuf {
    let result = env::current_dir().unwrap();
    result.join("test_folder")
}
@sagiegurari
Copy link
Owner

generated on runtime and then to run it on your working directory I'm adding a cd command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants