diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 22c7d8e6d6..283ebc9a31 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -17,6 +17,7 @@ use deno_runtime::permissions::parse_sys_kind; use log::debug; use log::Level; use std::env; +use std::ffi::OsString; use std::net::SocketAddr; use std::num::NonZeroU32; use std::num::NonZeroU8; @@ -909,7 +910,7 @@ To evaluate code in the shell: ); /// Main entry point for parsing deno's command line flags. -pub fn flags_from_vec(args: Vec) -> clap::error::Result { +pub fn flags_from_vec(args: Vec) -> clap::error::Result { let mut app = clap_root(); let mut matches = app.try_get_matches_from_mut(&args)?; @@ -4294,7 +4295,7 @@ mod tests { /// Creates vector of strings, Vec macro_rules! svec { - ($($x:expr),* $(,)?) => (vec![$($x.to_string()),*]); + ($($x:expr),* $(,)?) => (vec![$($x.to_string().into()),*]); } #[test] diff --git a/cli/lsp/testing/execution.rs b/cli/lsp/testing/execution.rs index 6b89f0e43e..e1189ec2cb 100644 --- a/cli/lsp/testing/execution.rs +++ b/cli/lsp/testing/execution.rs @@ -212,7 +212,7 @@ impl TestRun { ) -> Result<(), AnyError> { let args = self.get_args(); lsp_log!("Executing test run with arguments: {}", args.join(" ")); - let flags = flags_from_vec(args.into_iter().map(String::from).collect())?; + let flags = flags_from_vec(args.into_iter().map(From::from).collect())?; let factory = CliFactory::from_flags(flags)?; // Various test files should not share the same permissions in terms of // `PermissionsContainer` - otherwise granting/revoking permissions in one diff --git a/cli/main.rs b/cli/main.rs index 729559d9a1..32e40ff513 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -320,7 +320,7 @@ pub fn main() { Box::new(util::draw_thread::DrawThread::show), ); - let args: Vec = env::args().collect(); + let args: Vec<_> = env::args_os().collect(); // NOTE(lucacasonato): due to new PKU feature introduced in V8 11.6 we need to // initialize the V8 platform on a parent thread of all threads that will spawn diff --git a/cli/mainrt.rs b/cli/mainrt.rs index ae4ea727f8..56bde7c4b6 100644 --- a/cli/mainrt.rs +++ b/cli/mainrt.rs @@ -68,10 +68,9 @@ fn unwrap_or_exit(result: Result) -> T { } fn main() { - let args: Vec = env::args().collect(); + let args: Vec<_> = env::args_os().collect(); let current_exe_path = current_exe().unwrap(); - let standalone = - standalone::extract_standalone(¤t_exe_path, args.clone()); + let standalone = standalone::extract_standalone(¤t_exe_path, args); let future = async move { match standalone { Ok(Some(future)) => { diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index 2b334ec466..a3a12f5e20 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -2,6 +2,7 @@ use std::collections::BTreeMap; use std::env::current_exe; +use std::ffi::OsString; use std::fs; use std::future::Future; use std::io::Read; @@ -239,7 +240,7 @@ pub fn is_standalone_binary(exe_path: &Path) -> bool { /// the bundle is executed. If not, this function exits with `Ok(None)`. pub fn extract_standalone( exe_path: &Path, - cli_args: Vec, + cli_args: Vec, ) -> Result< Option>>, AnyError, @@ -281,7 +282,10 @@ pub fn extract_standalone( .context("Failed to read metadata from the current executable")?; let mut metadata: Metadata = serde_json::from_str(&metadata).unwrap(); - metadata.argv.append(&mut cli_args[1..].to_vec()); + metadata.argv.reserve(cli_args.len() - 1); + for arg in cli_args.into_iter().skip(1) { + metadata.argv.push(arg.into_string().unwrap()); + } Ok((metadata, eszip)) }))