Fix readonly variable crash in non-tty environments#5
Open
ChristopherA wants to merge 1 commit intomainfrom
Open
Fix readonly variable crash in non-tty environments#5ChristopherA wants to merge 1 commit intomainfrom
ChristopherA wants to merge 1 commit intomainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setup_Terminal_Capabilities()crashes with "read-only variable: Term_Reset" in non-tty environments (SSH without TTY, CI, piped execution)Term_Resetas readonly viatypeset -r -g. In non-tty contexts,tput sgr0fails and the value is empty but still readonly-z), sees empty, tries to re-set it -- crashes because the variable is readonlytypeset -p) instead of emptiness (-z). A readonly empty variable is still declaredReproduction
Test plan