Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read-only variable: status #634

Closed
uhlhosting opened this issue Dec 10, 2020 · 7 comments
Closed

read-only variable: status #634

uhlhosting opened this issue Dec 10, 2020 · 7 comments
Labels
bug zsh Related to Zsh specific implemetation
Milestone

Comments

@uhlhosting
Copy link

uhlhosting commented Dec 10, 2020

Shell: ZSH 5.8

Operating system: Darwin Revenger.local 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64

Liquidprompt version: v2.0.0-beta.1: 6e7f4c7

Steps to Reproduce

  1. deployed with zplugin
  2. opened a new terminal

Expected Behavior

No errors.

Current Behavior

Each prompt displays this error:
read-only variable: status

@uhlhosting uhlhosting added the bug label Dec 10, 2020
@Rycieos Rycieos added the needs information More information needed from the reporter label Dec 10, 2020
@Rycieos
Copy link
Collaborator

Rycieos commented Dec 10, 2020

I can not reproduce this.

source ~/.zinit/bin/zinit.zsh
zinit load nojhan/liquidprompt

I see my normal prompt with no errors.

Could you post your .zshrc? And could you try without using zinit/zplugin?

@uhlhosting
Copy link
Author

uhlhosting commented Dec 10, 2020

zinit lucid load'![[ $MYPROMPT = 2 ]]' unload'![[ $MYPROMPT != 2 ]]' nocd for \
    nojhan/liquidprompt

This is how I load it.
Will update the loading way. And see if it helps.

@uhlhosting
Copy link
Author

I have several prompts and this was an addaptation to previous version, and it worked fine, only since the upgrade this message occured.

@Rycieos
Copy link
Collaborator

Rycieos commented Dec 10, 2020

I have tried your loading command and it works correctly for me.

If you remove the liquidprompt line does the error go away? What other plugins are you loading? What zsh options do you have set?

The only variable by the name of status in liquidprompt is in _lp_battery_color(). If you set LP_ENABLE_BATT=0 in your config, and run lp_activate to reload the config, does the problem go away?

@uhlhosting
Copy link
Author

https://github.com/zdharma/zinit-configs/blob/master/psprint/zshrc.zsh this is the zshrc model I use, ofcourse i have changed it since just not on terms of plugins modules much to affect this behaviour.

What is best way to edit the config in latest release? I used to have another config some time ago, havent been using this in some time.

@uhlhosting
Copy link
Author

uhlhosting commented Dec 10, 2020

I have changed the status, and followed the config, added the .liquid...rc file into ~/.config/. Its still the same, or should i place it directly in ~/.liquid..rc ?

I managed, it seems only ~/.liquidpromptrc loccation is read, the onne mentioed in docs with .config is not working. Disabling its gone the message.

image

There is still one last thing, not sure how to make the format of the prompt to be available at first opening terminal, now everytime I open it, I must first do some action and only then will activate the visible see printscreen.

@Rycieos
Copy link
Collaborator

Rycieos commented Dec 10, 2020

The config file location has not changed. See the Config docs.

~/.liquidpromptrc or ~/.config/liquidpromptrc (note no leading . on the second) would work.

now everytime I open it, I must first do some action and only then will activate the visible see printscreen.

I also see that behaviour when using the .zshrc that you linked. It seems to be caused by the load'![[ $MYPROMPT = 2 ]]' unload'![[ $MYPROMPT != 2 ]]' in the loading command. If you load Liquidprompt with a normal zinit load nojhan/liquidprompt that does not happen.

But now that you have confirmed it is that variable, I can reproduce this:

% _lp_battery() { lp_battery=20; }
% lp_activate
% LP_ENABLE_BATT=1
_lp_battery_color:6: read-only variable: status

And it happens without zinit.

According to this helpful answer: https://unix.stackexchange.com/a/407179/421569
status is a special variable, that apparently you can't even reuse if you declare it a local:

% for p in $parameters[(I)*]; do print $p $parameters[$p]; done | grep special | sort
$ integer-readonly-special
0 scalar-special
aliases association-hide-hideval-special
ARGC integer-readonly-special
argv array-special
* array-readonly-special
@ array-readonly-special
builtins association-readonly-hide-hideval-special
cdpath array-special
CDPATH scalar-special
COLUMNS integer-special
commands association-hide-hideval-special
dirstack array-hide-hideval-special
dis_aliases association-hide-hideval-special
dis_builtins association-readonly-hide-hideval-special
dis_functions association-hide-hideval-special
dis_galiases association-hide-hideval-special
dis_patchars array-readonly-hide-hideval-special
dis_reswords array-readonly-hide-hideval-special
dis_saliases association-hide-hideval-special
EGID integer-special
EUID integer-special
fignore array-special
FIGNORE scalar-special
fpath array-special
FPATH scalar-special
funcfiletrace array-readonly-hide-hideval-special
FUNCNEST integer-special
funcsourcetrace array-readonly-hide-hideval-special
funcstack array-readonly-hide-hideval-special
functions association-hide-hideval-special
functrace array-readonly-hide-hideval-special
galiases association-hide-hideval-special
GID integer-special
histchars scalar-special
HISTCHARS scalar-special
HISTCMD integer-readonly-special
history association-readonly-hide-hideval-special
historywords array-readonly-hide-hideval-special
HISTSIZE integer-export-special
HOME scalar-export-special
IFS scalar-special
! integer-readonly-special
# integer-readonly-special
? integer-readonly-special
jobdirs association-readonly-hide-hideval-special
jobstates association-readonly-hide-hideval-special
jobtexts association-readonly-hide-hideval-special
KEYBOARD_HACK scalar-special
keymaps array-readonly-hide-hideval-special
LANG scalar-export-special
LINENO integer-readonly-special
LINES integer-special
mailpath array-special
MAILPATH scalar-special
manpath array-special
MANPATH scalar-special
module_path array-special
MODULE_PATH scalar-special
modules association-readonly-hide-hideval-special
nameddirs association-hide-hideval-special
NULLCMD scalar-special
OPTARG scalar-special
OPTIND integer-special
options association-hide-hideval-special
parameters association-readonly-hide-hideval-special
patchars array-readonly-hide-hideval-special
path array-special
PATH scalar-export-special
pipestatus array-special
PPID integer-readonly-special
PROMPT2 scalar-special
PROMPT3 scalar-special
PROMPT4 scalar-special
prompt scalar-special
PROMPT scalar-special
PS1 scalar-export-special
PS2 scalar-special
PS3 scalar-special
PS4 scalar-special
psvar array-special
PSVAR scalar-special
RANDOM integer-special
READNULLCMD scalar-special
reswords array-readonly-hide-hideval-special
saliases association-hide-hideval-special
SAVEHIST integer-special
scalar-readonly-special
_ scalar-special
SECONDS integer-special
SHLVL integer-export-special
SPROMPT scalar-special
status integer-readonly-special
termcap association-readonly-hide-hideval-special
terminfo association-readonly-hide-hideval-special
TERM scalar-export-special
TRY_BLOCK_ERROR integer-special
TRY_BLOCK_INTERRUPT integer-special
TTYIDLE integer-readonly-special
UID integer-special
userdirs association-readonly-hide-hideval-special
USERNAME scalar-special
watch array-special
WATCH scalar-special
widgets association-readonly-hide-hideval-special
WORDCHARS scalar-special
zsh_eval_context array-readonly-special
ZSH_EVAL_CONTEXT scalar-readonly-special
zsh_scheduled_events array-readonly-hide-hideval-special
ZSH_SUBSHELL integer-readonly-special

Thanks zsh.

But this is confirmed a bug introduced in v2.0.0-beta.1: f3f20ec
I'll add a fix shortly.

@Rycieos Rycieos added zsh Related to Zsh specific implemetation and removed needs information More information needed from the reporter labels Dec 10, 2020
@Rycieos Rycieos added this to the v2.0 milestone Dec 10, 2020
pkkolos pushed a commit to pkkolos/liquidprompt that referenced this issue May 9, 2021
Some zsh variable names just can not be used, even when declaring them
as local. 'status' and 'path' are such vars. For some reason, declaring
'path' as a local seems to work, but 'status' does not. The command:

for p in $parameters[(I)*]; do print $p $parameters[$p]; done | grep special | sort

will print all zsh special variables.

Rename them to prevent any possible issues.

Fixes liquidprompt#634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug zsh Related to Zsh specific implemetation
Projects
None yet
Development

No branches or pull requests

2 participants