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

Does not work with 'set -o nounset' because of undefined variables usage #354

Closed
cyril-bouthors opened this issue Mar 20, 2015 · 5 comments
Assignees
Labels
enhancement Feature request
Milestone

Comments

@cyril-bouthors
Copy link

Liquidprompt does not work when enabling the BASH 'nounset' feature, each prompt shows the three following warnings:

09:08:57 θ81° [cyb@home:~] $ set -o nounset
-bash: ret: unbound variable
-bash: LP_TIME_ANALOG: unbound variable
-bash: http_proxy: unbound variable
09:09:02 θ81° [cyb@home:~] $ 

Would it be possible to make sure variables are defined before using them?

@dolmen
Copy link
Collaborator

dolmen commented Mar 30, 2015

For reference (at least for myself), here is the relevant part of the bash manual about nounset:

Treat unset variables and parameters other than the special parameters "@" and "*" as an error when performing parameter expansion. If expansion is attempted on an unset variable or parameter, the shell prints an error message, and, if not interactive, exits with a non-zero status.

About your question, I think it would be a big effort (if even possible) to make liquidprompt clean for nounset. Note that would require testing with nounset not just the runtime, but also checking the initial loading of liquidprompt (that currently raises more errors).

I don't intend to spend my own time resources on this effort, but patches are welcome!

Note that on Ubuntu, filename completion seems to have issues working with nounset, so just fixing liquidprompt would not be enough for a clean user experience with nounset.

@dolmen dolmen added the enhancement Feature request label Apr 23, 2015
@dolmen
Copy link
Collaborator

dolmen commented Apr 29, 2015

Related: #360 (fixed by #361).

@dolmen
Copy link
Collaborator

dolmen commented May 18, 2015

bash-completion (which is something most liquidprompt+bash users will use, as I do myself) is not yet nounset-safe. This is on bash-completion roadmap for 3.0.

Anyway, I have some work in progress for liquidprompt in the fix/usage-of-undef-variables branch...

@dolmen dolmen self-assigned this May 19, 2015
dolmen added a commit that referenced this issue Dec 9, 2015
set -o nounset
I've only fixed usage of variable that were used at runtime in my
environment. 'ret' remains unfixed.
@dolmen
Copy link
Collaborator

dolmen commented Dec 9, 2015

I've fixed all cases I found so far with a8114dd.

pkkolos pushed a commit to pkkolos/liquidprompt that referenced this issue Dec 11, 2015
set -o nounset
I've only fixed usage of variable that were used at runtime in my
environment. 'ret' remains unfixed.
@Rycieos Rycieos added this to the v2.0 milestone Jun 30, 2020
@Rycieos
Copy link
Collaborator

Rycieos commented Dec 9, 2020

I have both manually inspected the source for set -u errors as well as tested thoroughly. This is now greatly improved in v2.0.0-beta.1.

However, as dolmen noted in #354 (comment), bash-completion still does not support set -u, so I can't run set -u on my daily driver shells. There might still be some edge case I failed to catch. Please open a new issue if you find one.

@Rycieos Rycieos closed this as completed Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request
Projects
None yet
Development

No branches or pull requests

3 participants