Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.47k stars 947 forks source link

+vi-git-untracked should quote output from `git ls-files` #1251

Open tlrdstd opened 5 years ago

tlrdstd commented 5 years ago

https://github.com/bhilburn/powerlevel9k/blob/master/functions/vcs.zsh#L18 is:

local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)

and should be:

local untrackedFiles="$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)"

per https://unix.stackexchange.com/a/208622 about Zsh word-splitting.

Simple repro:

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
# in a clean git repo
mkdir untrackedDir && touch untrackedDir/one && touch untrackedDir/two
+vi-git-untracked:local:8: not valid in this context: untrackedDir/two

Impact:

tlrdstd commented 5 years ago

Believe this is the root cause of #1101

Turiok commented 5 years ago

I have this problem and the correction works for me. Thx

romkatv commented 5 years ago

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

tlrdstd commented 5 years ago

@romkatv 5.0.7 :-/ I have a weird mix of Zsh versions, and hadn't realized when I filed this ticket that my work system is actually launching the older one. If you need to close this due to lack of support for old versions, I understand.

romkatv commented 5 years ago

It's not my call (I'm not a Powerlevel9k dev) but https://github.com/bhilburn/powerlevel9k/wiki/Minimum-System-Requirements says the minimum supported version is 5.1.

romkatv commented 5 years ago

To the devs: In Powerlevel10k, to avoid confusion when people have multiple versions of zsh installed, I have this piece of code at the top:

if ! autoload -U is-at-least || ! is-at-least 5.1; then
  () {
    >&2 echo -E "You are using ZSH version $ZSH_VERSION. The minimum required version for Powerlevel10k is 5.1."
    >&2 echo -E "Type 'echo \$ZSH_VERSION' to see your current zsh version."
    local def=${SHELL:c:A}
    local cur=${${ZSH_ARGZERO#-}:c:A}
    local cur_v=$($cur -c 'echo -E $ZSH_VERSION' 2>/dev/null)
    if [[ $cur_v == $ZSH_VERSION && $cur != $def ]]; then
      >&2 echo -E "The shell you are currently running is likely $cur."
    fi
    local other=${${:-zsh}:c}
    if [[ -n $other ]] && $other -c 'autoload -U is-at-least && is-at-least 5.1' &>/dev/null; then
      local other_v=$($other -c 'echo -E $ZSH_VERSION' 2>/dev/null)
      if [[ -n $other_v && $other_v != $ZSH_VERSION ]]; then
        >&2 echo -E "You have $other with version $other_v but this is not what you are using."
        if [[ -n $def && $def != ${other:A} ]]; then
          >&2 echo -E "To change your user shell, type the following command:"
          >&2 echo -E ""
          if [[ $(grep -F $other /etc/shells 2>/dev/null) != $other ]]; then
            >&2 echo -E "  echo ${(q-)other} | sudo tee -a /etc/shells"
          fi
          >&2 echo -E "  chsh -s ${(q-)other}"
        fi
      fi
    fi
  }
  return 1
fi

Consider adding something like this.

chandrahas-abburi commented 5 years ago

My version on centos is 5.0.2 and i cant upgrade from it. any leads on what i can do?

Turiok commented 5 years ago

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

Sorry @romkatv I didn't see your comment. My version of ZSH is 5.7.1

romkatv commented 5 years ago

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

Sorry @romkatv I didn't see your comment. My version of ZSH is 5.7.1

Did you get it from zsh --version or from echo $ZSH_VERSION?

Turiok commented 5 years ago

My version on centos is 5.0.2 and i cant upgrade from it. any leads on what i can do?

Hi @chandrahas-abburi,

For my case I compiled zsh with the version 5.7.1

Turiok commented 5 years ago

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

Sorry @romkatv I didn't see your comment. My version of ZSH is 5.7.1

Did you get it from zsh --version or from echo $ZSH_VERSION?

It was echo $ZSH_VERSION.

echo $ZSH_VERSION
5.7.1
zsh --version
zsh 5.7.1 (x86_64-pc-linux-gnu)
romkatv commented 5 years ago

@Turiok

You get an error on vi-git-untracked:local:8 when using zsh 5.7.1? This is surprising because that error is caused by a bug in ZSH that was fixed in 5.1.

Perhaps you can try adding echo $ZSH_VERSION to vi-git-untracked to make sure it's indeed zsh 5.7.1 that executes the function and produces the error?

romkatv commented 5 years ago

@chandrahas-abburi

My version on centos is 5.0.2 and i cant upgrade from it. any leads on what i can do?

There are a few options.