Skip to content

Fix readonly variable crash in non-tty environments#5

Open
ChristopherA wants to merge 1 commit intomainfrom
fix/non-tty-readonly-variable
Open

Fix readonly variable crash in non-tty environments#5
ChristopherA wants to merge 1 commit intomainfrom
fix/non-tty-readonly-variable

Conversation

@ChristopherA
Copy link
Contributor

Summary

  • setup_Terminal_Capabilities() crashes with "read-only variable: Term_Reset" in non-tty environments (SSH without TTY, CI, piped execution)
  • Line 302 sets Term_Reset as readonly via typeset -r -g. In non-tty contexts, tput sgr0 fails and the value is empty but still readonly
  • Line 1450 checks emptiness (-z), sees empty, tries to re-set it -- crashes because the variable is readonly
  • Fix: check variable existence (typeset -p) instead of emptiness (-z). A readonly empty variable is still declared

Reproduction

ssh host 'source /path/to/_Z_Utils.zsh'
# Output: setup_Terminal_Capabilities:4: read-only variable: Term_Reset

Test plan

  • Verify in non-tty environment (SSH without TTY)
  • Verify no regression in TTY environment
  • Verify setup_git_inception_repo.sh works over SSH

setup_Terminal_Capabilities checked Term_Reset with -z (emptiness),
but in non-tty contexts tput fails and Term_Reset gets set to empty
string as readonly at line 302. The -z check sees "empty", tries to
re-set it, and crashes with "read-only variable".

Fix: check variable existence (typeset -p) instead of emptiness (-z).
A readonly empty variable is still declared — it just has no value.

Reproduces via: ssh host 'source _Z_Utils.zsh' or any non-tty context.

Signed-off-by: Christopher Allen <ChristopherA@LifeWithAlacrity.com>
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