1
>
/*---------------------------------------------------------------------------------------------
codexShellCommand.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
/**
7
>
* Codex reports a shell command as the exact invocation it hands to the OS —
8
>
* the user's login shell wrapping the actual script, e.g.
9
>
* `/bin/zsh -lc 'touch ~/foo'`. That wrapper is noise in the chat UI and makes
10
>
* Codex's terminal pills (and its approval / denial cards) look different from
11
>
* Claude's (which surface the bare `touch ~/foo`). Peel off a leading
12
>
* `<shell> -[l]c <script>` wrapper and return the inner script so both agents
13
>
* render identically. Falls back to the raw command when it doesn't match the
14
>
* wrapper shape.
15
>
*
16
>
* This is a display-only transform: callers must keep the raw command for any
17
>
* identity/round-trip purpose (accept-for-session memo keys, re-sending the
18
>
* exact action to the app-server, etc.).
19
>
*/
20
>
export function unwrapShellInvocation(command: string): string {
21
const match = /^\s*\S*sh(?:\.exe)?\s+-[a-z]*c\s+([\s\S]+)$/i.exec(command);
22
if (!match) {