diff --git a/Cargo.lock b/Cargo.lock index b13fae5..57255c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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)", diff --git a/Cargo.toml b/Cargo.toml index 3ec3750..9fde917 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "osenv" -version = "0.1.0" +version = "1.0.0" authors = ["Hamcha "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index b304934..17c36d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,10 @@ fn get_file(cmd: &ArgMatches) -> Option { 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),