Skip to content

Commit deea943

Browse files
authored
refactor!: changed Env.args to Env.args_os and use OsString instead of String (#7876)
ref: #7756
1 parent 092a561 commit deea943

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

.changes/tauri-env-args.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri': 'major:breaking'
3+
---
4+
5+
Changed `Env.args` to `Env.args_os` and now uses `OsString` instead of `String`

core/tauri-utils/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![allow(clippy::deprecated_semver)]
1515

1616
use std::{
17+
ffi::OsString,
1718
fmt::Display,
1819
path::{Path, PathBuf},
1920
};
@@ -275,21 +276,21 @@ pub struct Env {
275276
#[cfg(target_os = "linux")]
276277
pub appdir: Option<std::ffi::OsString>,
277278
/// The command line arguments of the current process.
278-
pub args: Vec<String>,
279+
pub args_os: Vec<OsString>,
279280
}
280281

281282
#[allow(clippy::derivable_impls)]
282283
impl Default for Env {
283284
fn default() -> Self {
284-
let args = std::env::args().skip(1).collect();
285+
let args_os = std::env::args_os().skip(1).collect();
285286
#[cfg(target_os = "linux")]
286287
{
287288
let env = Self {
288289
#[cfg(target_os = "linux")]
289290
appimage: std::env::var_os("APPIMAGE"),
290291
#[cfg(target_os = "linux")]
291292
appdir: std::env::var_os("APPDIR"),
292-
args,
293+
args_os,
293294
};
294295
if env.appimage.is_some() || env.appdir.is_some() {
295296
// validate that we're actually running on an AppImage
@@ -312,7 +313,7 @@ impl Default for Env {
312313
}
313314
#[cfg(not(target_os = "linux"))]
314315
{
315-
Self { args }
316+
Self { args_os }
316317
}
317318
}
318319
}

core/tauri/src/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn restart(env: &Env) {
7676

7777
if let Ok(path) = current_binary(env) {
7878
Command::new(path)
79-
.args(&env.args)
79+
.args(&env.args_os)
8080
.spawn()
8181
.expect("application failed to start");
8282
}

core/tests/restart/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
match argv.nth(1).as_deref() {
2222
Some("restart") => {
2323
let mut env = Env::default();
24-
env.args.clear();
24+
env.args_os.clear();
2525
tauri::process::restart(&env)
2626
}
2727
Some(invalid) => panic!("only argument `restart` is allowed, {invalid} is invalid"),

0 commit comments

Comments
 (0)