pub struct ShellScript {
pub script_path: Exe,
}
Expand description
Execute a command line beginning with this shell script.
The later arguments provided via Self::with_command
(FIXME!)
use std::io::Write;
use tempfile::NamedTempFile;
use super_process::{sh, exe, sync::SyncInvocable, base::CommandBase, fs};
let script_path = {
let (mut script_file, script_path) = NamedTempFile::new().unwrap().into_parts();
script_file.write_all(b"echo hey\n").unwrap();
script_file.sync_all().unwrap();
script_path.keep().unwrap()
};
let script_path = exe::Exe(fs::File(script_path));
let script = sh::ShellScript { script_path };
let command = script.with_command(exe::Command::default())
.setup_command().await.unwrap();
let output = command.invoke().await.expect("script should succeed");
assert!(b"hey\n".as_ref() == &output.stdout);
Fields§
§script_path: Exe
The script to execute.
Implementations§
Source§impl ShellScript
impl ShellScript
Sourcepub fn with_command(self, base: Command) -> ShellScriptInvocation
pub fn with_command(self, base: Command) -> ShellScriptInvocation
Provide a command line for this shell script to execute.
Trait Implementations§
Source§impl Clone for ShellScript
impl Clone for ShellScript
Source§fn clone(&self) -> ShellScript
fn clone(&self) -> ShellScript
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ShellScript
impl RefUnwindSafe for ShellScript
impl Send for ShellScript
impl Sync for ShellScript
impl Unpin for ShellScript
impl UnwindSafe for ShellScript
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more