Under systemd, pane commands have $VAR and $$ expanded by systemd-run #57

Closed
opened 2026-10-02 10:54:07 +00:00 by jhgaylor · 1 comment
Owner

Panes start through systemd-run --user --scope, which since systemd 254 expands $VAR/${VAR} (from the manager environment) and turns $$ into $ in the command before the shell sees it. So illogical run "echo $$" printed $, and any $VAR in a run/restore command got the manager's value or nothing. Also, panes inherited the service's NOTIFY_SOCKET/LISTEN_*/INVOCATION_ID, so a dev daemon started in a pane took itself for the systemd service (scopes, FD store).

Found while fixing the macOS CI (questions.rs claude_code_in_a_terminal_asks_through_its_hook fails when cargo test runs inside a pane of the systemd daemon). Fixed on branch ci-mac-fix: --expand-environment=no when systemd-run is >= 254, and the service env is removed from panes and agents. Test: a_command_reaches_its_shell_as_written_under_systemd.

Panes start through `systemd-run --user --scope`, which since systemd 254 expands `$VAR`/`${VAR}` (from the manager environment) and turns `$$` into `$` in the command before the shell sees it. So `illogical run "echo $$"` printed `$`, and any `$VAR` in a run/restore command got the manager's value or nothing. Also, panes inherited the service's NOTIFY_SOCKET/LISTEN_*/INVOCATION_ID, so a dev daemon started in a pane took itself for the systemd service (scopes, FD store). Found while fixing the macOS CI (questions.rs `claude_code_in_a_terminal_asks_through_its_hook` fails when `cargo test` runs inside a pane of the systemd daemon). Fixed on branch `ci-mac-fix`: `--expand-environment=no` when systemd-run is >= 254, and the service env is removed from panes and agents. Test: `a_command_reaches_its_shell_as_written_under_systemd`.
Author
Owner

Fixed on main in 3aa929c (merge of ci-mac-fix, 55962d3): systemd-run gets --expand-environment=no on 254+, and the service's own environment (sys::SERVICE_ENV) no longer reaches panes or agents. Test: a_command_reaches_its_shell_as_written_under_systemd. Found during #55.

Fixed on main in 3aa929c (merge of ci-mac-fix, 55962d3): systemd-run gets --expand-environment=no on 254+, and the service's own environment (sys::SERVICE_ENV) no longer reaches panes or agents. Test: a_command_reaches_its_shell_as_written_under_systemd. Found during #55.
jhgaylor referenced this issue from a commit 2026-10-02 12:48:47 +00:00
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jhgaylor/illogical#57
No description provided.