use std::sync::Arc;
use bash_strings::emit_array;
use crate::rig::wire::Account;
use crate::rig::{Micros, Shell, Stamp};
pub fn account(pid: u32, zero: &str, flags: &str) -> Vec<String> {
let versinfo = emit_array(&["5", "3", "9", "1", "release", "x86_64-pc-linux-gnu"].map(String::from));
let command = if flags.contains('c') { "true" } else { "" };
let pid = pid.to_string();
[
"pid",
pid.as_str(),
"shlvl",
"5",
"subshell",
"0",
"versinfo",
versinfo.as_str(),
"bash",
"/usr/bin/bash",
"zero",
zero,
"flags",
flags,
"shellopts",
"braceexpand:hashall",
"bashopts",
"checkwinsize",
"command",
command,
"brought",
"()",
]
.iter()
.map(ToString::to_string)
.collect()
}
pub fn shell(nth: usize, pid: u32, zero: &str, flags: &str) -> Arc<Shell> {
let stamp = Stamp {
sent_at: Micros(100),
heard_at: Micros(101),
};
Arc::new(
Shell::of(
nth,
Account {
stamp,
words: account(pid, zero, flags),
},
)
.expect("an account"),
)
}
pub fn reading(zero: &str) -> Arc<Shell> {
shell(0, 7, zero, "hB")
}
pub fn given(zero: &str) -> Arc<Shell> {
shell(0, 7, zero, "hBc")
}