Skip to content

Instantly share code, notes, and snippets.

@sebglazebrook
Created June 10, 2016 10:46
Show Gist options
  • Save sebglazebrook/8657426f9ab6b4f32820cd01bb6a858f to your computer and use it in GitHub Desktop.
Save sebglazebrook/8657426f9ab6b4f32820cd01bb6a858f to your computer and use it in GitHub Desktop.
let file_path = "my.test".to_string();
let mut file = File::create(file_path).unwrap();
file.write_all("ls".as_bytes());
let mut process = Command::new("source")
.arg(file_path)
.spawn()
.unwrap_or_else(|e| { panic!("failed to execute child: {}", e) });
@sebglazebrook
Copy link
Author

Returns an error:

thread '<main>' panicked at 'failed to execute child: No such file or directory (os error 2)'

but if I change the command from source to ls then it finds the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment