Skip to content

[Bug]: atuin pty-proxy init exports SHELL=zsh instead of the spawned shell path #3606

Description

@hangrymuppet

What did you expect to happen?

When Atuin pty-proxy launches a proxied zsh session, $SHELL should remain an executable path for the shell that launched Atuin.

For example, on a macOS system whose terminal launches the login shell as /bin/zsh, the proxied session should keep:

SHELL=/bin/zsh

This matters because many tools correctly expect $SHELL to refer to an executable path.

What happened?

atuin pty-proxy init can launch the proxied zsh with:

SHELL=zsh

Atuin doctor output

{
  "atuin": {
    "version": "18.17.0",
    "commit": "",
    "sync": {
      "auth_state": "Hub (legacy token — run 'atuin login' to upgrade)",
      "records": true,
      "auto_sync": true,
      "last_sync": "REDACTED"
    },
    "sqlite_version": "3.46.0",
    "daemon_enabled": true
  },
  "shell": {
    "name": "zsh",
    "default": "zsh",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Darwin",
    "arch": "arm64",
    "version": "26.5.2",
    "disks": [
      {
        "name": "Macintosh HD",
        "filesystem": "apfs"
      },
      {
        "name": "Macintosh HD",
        "filesystem": "apfs"
      }
    ]
  }
}

Shell setup

The shell startup runs Atuin pty-proxy early:

if [[ "$-" == *i* ]] && command -v atuin >/dev/null 2>&1; then
  eval "$(atuin pty-proxy init)"
fi

The generated zsh init code currently uses ZSH_ARGZERO directly after
stripping a leading login-shell dash:

_atuin_pty_proxy_zsh="${ZSH_ARGZERO:-$(command -v zsh)}"
exec atuin pty-proxy --shell "${_atuin_pty_proxy_zsh#-}"

In the affected proxied session:

ATUIN_PTY_PROXY_ACTIVE=1
ATUIN_PTY_PROXY_SOCKET=/var/folders/.../T/atuin-pty-proxy-70454.sock
SHELL=zsh                    # <-- not an executable path
argv0=zsh
ZSH_ARGZERO=zsh
command -v zsh=/opt/homebrew/bin/zsh
ZSH_VERSION=5.9.1            # PATH shell version, not the launch shell version
SHELL is not executable      # [ -x "$SHELL" ] returns false

With Atuin pty-proxy disabled in the same terminal environment:

SHELL=/bin/zsh               # <-- the expected executable path
argv0=-zsh
ZSH_ARGZERO=-zsh
command -v zsh=/opt/homebrew/bin/zsh
ZSH_VERSION=5.9              # launch shell version
SHELL is executable          # [ -x "$SHELL" ] returns true

Snippet to produce the above output:

env | rg '^(SHELL|ATUIN_PTY_PROXY_ACTIVE|ATUIN_PTY_PROXY_SOCKET)='
printf 'argv0=%s\n' "$0"
printf 'ZSH_ARGZERO=%s\n' "$ZSH_ARGZERO"
printf 'command -v zsh=%s\n' "$(command -v zsh)"
printf 'ZSH_VERSION=%s\n' "$ZSH_VERSION"
[[ -x "$SHELL" ]] && echo "SHELL is executable" || echo "SHELL is not executable"

Why this appears to be a regression

PR #3548 intentionally changed the pty-proxy runtime to set $SHELL to the
spawned shell:

cmd.env("SHELL", path);

That intent makes sense, but the generated zsh init path can pass a non-path
value from ZSH_ARGZERO:

atuin pty-proxy --shell zsh

Before #3548, this bad --shell zsh value may not have overwritten an inherited
absolute $SHELL. After #3548, it becomes visible as SHELL=zsh.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions