diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-03 01:32:22 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-03 01:32:22 +0300 |
| commit | daf636fef7fd68bcb1e30cfb155883c3b831513c (patch) | |
| tree | e3f8403b964ebb16c54cf1d0650511179e713687 /src | |
| parent | a1ba035707cfb3c83fad541ecd32ccbd7be58815 (diff) | |
fix: preserve child argv flags after separator
refs #383
Diffstat (limited to 'src')
| -rw-r--r-- | src/remote.rs | 25 | ||||
| -rw-r--r-- | src/session.rs | 49 |
2 files changed, 74 insertions, 0 deletions
diff --git a/src/remote.rs b/src/remote.rs index cd53344b..ce56ba8a 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -72,6 +72,10 @@ pub(crate) fn extract_remote_args( let mut index = 1; while index < args.len() { let arg = &args[index]; + if arg == "--" { + cleaned.extend_from_slice(&args[index..]); + break; + } if arg == "--handoff" { live_handoff = true; index += 1; @@ -1844,6 +1848,27 @@ mod tests { } #[test] + fn extract_remote_args_preserves_child_remote_options_after_separator() { + let args = vec![ + "herdr".into(), + "agent".into(), + "start".into(), + "repro".into(), + "--".into(), + "child".into(), + "--remote".into(), + "dev".into(), + "--remote-keybindings=server".into(), + "--handoff".into(), + ]; + + let (cleaned, remote) = extract_remote_args(&args).unwrap(); + + assert_eq!(cleaned, args); + assert!(remote.is_none()); + } + + #[test] fn extract_remote_args_preserves_handoff_without_remote() { let args = vec!["herdr".into(), "update".into(), "--handoff".into()]; diff --git a/src/session.rs b/src/session.rs index a4daf5e4..67b77dc0 100644 --- a/src/session.rs +++ b/src/session.rs @@ -52,6 +52,10 @@ pub fn configure_from_args(args: &[String]) -> Result<Vec<String>, String> { let mut index = 1; while index < args.len() { let arg = &args[index]; + if arg == "--" { + cleaned.extend_from_slice(&args[index..]); + break; + } if arg == "--session" { let Some(value) = args.get(index + 1) else { return Err("missing value for --session".to_string()); @@ -569,6 +573,51 @@ mod tests { } #[test] + fn configure_from_args_preserves_child_session_option_after_separator() { + let _guard = env_lock().lock().unwrap(); + std::env::remove_var(SESSION_ENV_VAR); + clear_explicit_session_for_test(); + let args = vec![ + "herdr".to_string(), + "agent".to_string(), + "start".to_string(), + "repro".to_string(), + "--".to_string(), + "/bin/echo".to_string(), + "--session".to_string(), + "child-session".to_string(), + ]; + + let cleaned = configure_from_args(&args).unwrap(); + + assert_eq!(cleaned, args); + assert!(std::env::var(SESSION_ENV_VAR).is_err()); + assert!(!explicit_session_requested()); + } + + #[test] + fn configure_from_args_preserves_child_session_equals_option_after_separator() { + let _guard = env_lock().lock().unwrap(); + std::env::remove_var(SESSION_ENV_VAR); + clear_explicit_session_for_test(); + let args = vec![ + "herdr".to_string(), + "agent".to_string(), + "start".to_string(), + "repro".to_string(), + "--".to_string(), + "/bin/echo".to_string(), + "--session=child-session".to_string(), + ]; + + let cleaned = configure_from_args(&args).unwrap(); + + assert_eq!(cleaned, args); + assert!(std::env::var(SESSION_ENV_VAR).is_err()); + assert!(!explicit_session_requested()); + } + + #[test] fn configure_from_args_rewrites_session_attach_to_default_launch() { let _guard = env_lock().lock().unwrap(); std::env::set_var(SESSION_ENV_VAR, "bad/name"); |
