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

modify declaration of dir variable in sections/dir #421

Merged
merged 7 commits into from
Jul 23, 2018
Merged

modify declaration of dir variable in sections/dir #421

merged 7 commits into from
Jul 23, 2018

Conversation

gurpreetatwal
Copy link
Contributor

@gurpreetatwal gurpreetatwal commented Apr 12, 2018

Description

potential fix for #420, feel free to close this PR if a better solution can be found

Fixes the issue by explicitly assigning the variable to prevent it from accidentally expanding the dir variable if there is a shell alias assigned to it.

Fix #420

salmanulfarzy
salmanulfarzy previously approved these changes Apr 20, 2018
Copy link
Member

@salmanulfarzy salmanulfarzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to reproduce the issue.

Edit: There was a mistake from my side during earlier reproducing attempts. This is reproducible and affects every unassigned initialized variables, Which have global alias defined with user configuration.

@salmanulfarzy salmanulfarzy added the improvement A PR that make small changes for improving UX, performance, readability, etc label Apr 25, 2018
salmanulfarzy
salmanulfarzy previously approved these changes May 5, 2018
Copy link
Member

@salmanulfarzy salmanulfarzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to go 👌

@gurpreetatwal do you consider to address the similar variable assignments ? If not, We could merge this.

sections/dir.zsh Outdated
@@ -21,7 +21,7 @@ SPACESHIP_DIR_COLOR="${SPACESHIP_DIR_COLOR="cyan"}"
spaceship_dir() {
[[ $SPACESHIP_DIR_SHOW == false ]] && return

local dir
local 'dir'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave a comment about using quotes here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be default behavior for all unassigned local variables. Documenting it in doc would be better than leaving a single comment.

@gurpreetatwal
Copy link
Contributor Author

@denysdovhan @salmanulfarzy rebased and cleaned up the PR

  • modified all instances of local <variable> to be local '<variable'>
  • updated example in API to link to the Zsh alias docs and include example of quoted local variable

@@ -27,7 +27,7 @@ spaceship_venv() {
# Check if the current directory running via Virtualenv
[ -n "$VIRTUAL_ENV" ] || return

local venv
local 'venv'
Copy link
Contributor Author

@gurpreetatwal gurpreetatwal Jul 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see this as being troublesome as well

example:

alias -g venv='python3 -m venv'

Copy link
Member

@salmanulfarzy salmanulfarzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@denysdovhan denysdovhan merged commit 2796da9 into spaceship-prompt:master Jul 23, 2018
@gurpreetatwal gurpreetatwal deleted the fix-local-variable branch July 23, 2018 17:08
denysdovhan added a commit that referenced this pull request May 27, 2021
modify declaration of dir variable in sections/dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement A PR that make small changes for improving UX, performance, readability, etc
Development

Successfully merging this pull request may close these issues.

declaration of dir variable in dir section causes exapansion of alias
3 participants