[PR #12906] Fix profile commandlines being overwritten by profile.defaults #29295

Open
opened 2026-01-31 09:34:04 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/12906

State: closed
Merged: Yes


#12149 introduced a bug where ClearCommandline() is called on any user
profile containing the non-canonical strings "cmd.exe" or "powershell.exe"
in the "commandline" field. If you happen to have set the "commandline"
field in your profiles.defaults, this will cause these user profiles
to adopt the base layer command-line instead of the defaults layer one.

This commit fixes the issue, by checking the command-line after the call
to ClearCommandline() and ensuring it's the expected string.

Additionally this moves the migration logic to SettingsLoader as this allows
us to write the fixed settings to disk, if any fixed had to be applied.

PR Checklist

Validation Steps Performed

  • The modified unit test fails without these changes
  • The modified unit test succeeds with these changes
  • Setting profiles.defaults.commandline to "pwsh.exe" and setting
    my "...\powershell.exe" profile to use just "powershell.exe" as
    the commandline, doesn't cause it to use "pwsh.exe"
    The fixed settings are written to settings.json
**Original Pull Request:** https://github.com/microsoft/terminal/pull/12906 **State:** closed **Merged:** Yes --- #12149 introduced a bug where `ClearCommandline()` is called on any user profile containing the non-canonical strings "cmd.exe" or "powershell.exe" in the "commandline" field. If you happen to have set the "commandline" field in your `profiles.defaults`, this will cause these user profiles to adopt the base layer command-line instead of the defaults layer one. This commit fixes the issue, by checking the command-line after the call to `ClearCommandline()` and ensuring it's the expected string. Additionally this moves the migration logic to `SettingsLoader` as this allows us to write the fixed settings to disk, if any fixed had to be applied. ## PR Checklist * [x] Closes #12842 * [x] I work here * [x] Tests added/passed ## Validation Steps Performed * The modified unit test fails without these changes ✅ * The modified unit test succeeds with these changes ✅ * Setting `profiles.defaults.commandline` to "pwsh.exe" and setting my "...\\powershell.exe" profile to use just "powershell.exe" as the `commandline`, doesn't cause it to use "pwsh.exe" ✅ The fixed settings are written to settings.json ✅
claunia added the pull-request label 2026-01-31 09:34:04 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29295