Skip to content

Fix login shell argv[0] parsed as flag in session files#10

Open
noomzopendream wants to merge 1 commit into
dflock:mainfrom
noomzopendream:fix/login-shell-argv-strip
Open

Fix login shell argv[0] parsed as flag in session files#10
noomzopendream wants to merge 1 commit into
dflock:mainfrom
noomzopendream:fix/login-shell-argv-strip

Conversation

@noomzopendream

Copy link
Copy Markdown

Login shells use a - prefix in argv[0] (e.g., -fish instead of fish) as a Unix exec convention. When this is written literally into a Kitty session file as:

launch -fish

Kitty's session parser interprets -f as an unknown flag:

Unknown flag: -f. Did you mean: -h?

Strip the leading - from the first cmdline element in cmdline_to_str() so login shells are emitted as launch fish — valid Kitty session syntax.

Reproduction

  1. Set fish (or any shell) as login shell
  2. kitty-save-session-all.sh saves a session with launch -fish
  3. kitty --detach --session=... fails with Unknown flag: -f

Fix

Check if the first element of the cmdline starts with - and is longer than 1 character (the login shell indicator), then strip it before writing to the session file.

Login shells use a '-' prefix in argv[0] (e.g., '-fish' instead of 'fish')
as a Unix convention. When this is written literally into a Kitty session
file as 'launch -fish', the session parser interprets '-f' as an unknown
flag, producing 'Unknown flag: -f. Did you mean: -h?'

Strip the leading '-' from the first cmdline element when saving sessions,
so login shells are written as 'launch fish' — valid Kitty session syntax.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant