Escape quotes on PS1
This commit is contained in:
parent
3658941098
commit
4269888e8c
3 changed files with 7 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -68,7 +68,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "osenv"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "osenv"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
authors = ["Hamcha <hamcha@crunchy.rocks>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -30,6 +30,10 @@ fn get_file(cmd: &ArgMatches) -> Option<PathBuf> {
|
|||
Some(Path::new(dir).join(filename))
|
||||
}
|
||||
|
||||
fn escape(raw: &str) -> String {
|
||||
raw.replace("\"", "`\"")
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
#[cfg(target_os = "macos")]
|
||||
static OS_DEFAULT_SHELL: &str = "sh";
|
||||
|
@ -116,7 +120,7 @@ fn main() -> std::io::Result<()> {
|
|||
println!(
|
||||
"$env:{} = \"{}\"; ",
|
||||
envline.get(..idx.unwrap()).unwrap(),
|
||||
envline.get(idx.unwrap() + 1..).unwrap()
|
||||
escape(envline.get(idx.unwrap() + 1..).unwrap())
|
||||
)
|
||||
}
|
||||
"sh" => println!("export {}", envline),
|
||||
|
|
Loading…
Reference in a new issue