Skip to content

Commit 6b5f8a4

Browse files
authored
feat: split wrapper command on linux (#4427)
* feat: split wrapper command on linux * feat: use code from #3900 * feat: also use shlex on Windows * feat: add a version number to global settings * feat(app): add settings v2, where wrapper command are split
1 parent 8b39ba4 commit 6b5f8a4

14 files changed

+152
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ serde-xml-rs = "0.8.1" # Also an XML (de)serializer, consider dropping yaserde
158158
sha1 = "0.10.6"
159159
sha1_smol = { version = "1.0.1", features = ["std"] }
160160
sha2 = "0.10.9"
161+
shlex = "1.3.0"
161162
spdx = "0.12.0"
162163
sqlx = { version = "0.8.6", default-features = false }
163164
sysinfo = { version = "0.37.2", default-features = false }

apps/app-frontend/src/helpers/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export type AppSettings = {
6767
skipped_update: string | null
6868
pending_update_toast_for_version: string | null
6969
auto_download_updates: boolean | null
70+
71+
version: number
7072
}
7173

7274
// Get full settings object
Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-6e3fa492c085ebb8e7280dd4d55cdcf73da199ea6ac05ee3ee798ece80d877cf.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ serde_json = { workspace = true }
7373
serde_with = { workspace = true }
7474
sha1_smol = { workspace = true }
7575
sha2 = { workspace = true }
76+
shlex = { workspace = true }
7677
sqlx = { workspace = true, features = [
7778
"json",
7879
"macros",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE settings ADD COLUMN version INTEGER NOT NULL DEFAULT 1;

packages/app-lib/src/api/profile/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,14 @@ async fn run_credentials(
666666
.filter(|hook_command| !hook_command.is_empty());
667667
if let Some(hook) = pre_launch_hooks {
668668
// TODO: hook parameters
669-
let mut cmd = hook.split(' ');
669+
let mut cmd = shlex::split(hook)
670+
.ok_or_else(|| {
671+
crate::ErrorKind::LauncherError(format!(
672+
"Invalid pre-launch command: {hook}",
673+
))
674+
})?
675+
.into_iter();
676+
670677
if let Some(command) = cmd.next() {
671678
let full_path = get_full_path(&profile.path).await?;
672679
let result = Command::new(command)

packages/app-lib/src/launcher/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,19 @@ pub async fn launch_minecraft(
567567
let args = version_info.arguments.clone().unwrap_or_default();
568568
let mut command = match wrapper {
569569
Some(hook) => {
570-
let mut command = Command::new(hook);
570+
let mut cmd = shlex::split(hook)
571+
.ok_or_else(|| {
572+
crate::ErrorKind::LauncherError(format!(
573+
"Invalid wrapper command: {hook}",
574+
))
575+
})?
576+
.into_iter();
577+
let mut command = Command::new(cmd.next().ok_or(
578+
crate::ErrorKind::LauncherError(
579+
"Empty wrapper command".to_owned(),
580+
),
581+
)?);
582+
command.args(cmd);
571583
command.arg(&java_version.path);
572584
command
573585
}

0 commit comments

Comments
 (0)