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

theme-preview.sh reports liquidprompt: line 2775: _LP_RUNTIME_SECONDS: unbound variable #656

Closed
LudovicRousseau opened this issue Feb 6, 2021 · 4 comments
Labels
bash Related to Bash specific implemetation bug
Milestone

Comments

@LudovicRousseau
Copy link

I try to generate theme preview.

Shell: ± bash 3.2.57(1)-release

Operating system: macOS Mojave 10.14.6, Darwin imac.xxx.fr 18.7.0 Darwin Kernel Version 18.7.0: Tue Jan 12 22:04:47 PST 2021; root:xnu-4903.278.56~1/RELEASE_X86_64 x86_64

Liquidprompt version: v2.0.0

Steps to Reproduce

  1. $ lp_theme --list
    default
  2. ± ./tools/theme-preview.sh default
    liquidprompt: line 2775: _LP_RUNTIME_SECONDS: unbound variable

Expected Behavior

I expect a nice theme preview.

Current Behavior

Error: liquidprompt: line 2775: _LP_RUNTIME_SECONDS: unbound variable

Possible Solution

I used export _LP_RUNTIME_SECONDS=0 I then get a new error:
liquidprompt: line 1368: _LP_ENABLED_VCSS[@]: unbound variable

@Rycieos
Copy link
Collaborator

Rycieos commented Feb 6, 2021

Ah, of course I failed to test that script under Bash-3.2. Should be a simple fix. I should add a test just to check that this script doesn't error.

Rycieos added a commit that referenced this issue Feb 6, 2021
Bash 3.2 scans a whole line for unset problems, unlike later versions,
which will exit the line if the boolean expression returns False
already. So we need to have a safe exit when unsafe for
_LP_RUNTIME_SECONDS on Bash 3.2.

This SO post is super helpful: https://stackoverflow.com/a/61551944/8338372
This is why the ${array[@]+"${array[@]}"} form is used, anywhere either
the arary could be empty, or the array could have empty strings as
values. Most of our array usages we know for sure there are good values
in, but user config ones we have no way to know for sure.

Also add an exit condition in the theme-preview where the passed in
theme does not exist.

Fixes #656
@Rycieos
Copy link
Collaborator

Rycieos commented Feb 6, 2021

I pushed 827fb9f that should fix this, could you give it a try please?

@LudovicRousseau
Copy link
Author

It works fine now.
I get:
theme

Rycieos added a commit that referenced this issue Feb 7, 2021
Bash 3.2 scans a whole line for unset problems, unlike later versions,
which will exit the line if the boolean expression returns False
already. So we need to have a safe exit when unsafe for
_LP_RUNTIME_SECONDS on Bash 3.2.

This SO post is super helpful: https://stackoverflow.com/a/61551944/8338372
This is why the ${array[@]+"${array[@]}"} form is used, anywhere either
the arary could be empty, or the array could have empty strings as
values. Most of our array usages we know for sure there are good values
in, but user config ones we have no way to know for sure.

Also add an exit condition in the theme-preview where the passed in
theme does not exist.

Add tests for the two tools scripts, just to check that they don't exit
with errors.

Fixes #656
@Rycieos Rycieos closed this as completed in e121179 Feb 7, 2021
@Rycieos Rycieos added the bash Related to Bash specific implemetation label Feb 7, 2021
@Rycieos Rycieos added this to the v2.0.1 milestone Feb 7, 2021
@Rycieos
Copy link
Collaborator

Rycieos commented Feb 7, 2021

v2.0.1 released, which fixes this issue. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash Related to Bash specific implemetation bug
Projects
None yet
Development

No branches or pull requests

2 participants