arialdomartini / oh-my-git

An opinionated git prompt for bash and zsh
MIT License
3.65k stars 286 forks source link

enrich_append:local:2: not valid in this context #34

Open mgryszko opened 9 years ago

mgryszko commented 9 years ago

After installing oh-my-git and your patched fonts, I'm getting this error on every shell execution:

enrich_append:local:2: not valid in this context: --

image

My environment:

arialdomartini commented 9 years ago

Hi, @mgryszko Thanks for the report! I'm having problems to reproduce this issue. I think it may depend on some required variable being null.

Does that problem arise in every repositories, or (so far) only in ~/.dotfile?

mgryszko commented 9 years ago

It happens in other (Git) directories as well.

Can you give me a hint, was enrich_append does, so I can investigate the problem myself?

arialdomartini commented 9 years ago

Hi @mgryszko. Well, the function enrich_append outputs a symbol or a space, depending on the value boolean flag.

If the flag is true, the symbol is displayed; if it's false, a space is displayed in place of the symbol.

The function accepts 3 arguments: the boolean flag, the symbol and the color.

For example, in order to display a white glyph "~" for untracked files, enrich_append could be called with the arguments

enrich_append $has_untracked_files "~" $white

The body of the function currently is

  function enrich_append {
        local flag=$1
        local symbol=$2
        local color=${3:-$omg_default_color_on}
        if [[ $flag == false ]]; then symbol=' '; fi

        echo -n "${color}${symbol}  "
    }

Could you please keep in touch with me, should you be able to find the bug? I'd appreciate it a lot.

arialdomartini commented 9 years ago

I suggest you to use the XTRACE option of zsh (which you can activate running zsh with -x): it helps to understand the parameters passed to enrich_append. I suspect one of your symbols is somehow null.

http://bolyai.cs.elte.hu/zsh-manual/zsh_16.html

mattatcha commented 9 years ago

@arialdomartini I am having the same errors here is the relevant part of xtrace.

+enrich_append:2> local 'symbol=' -- --
enrich_append:local:2: not valid in this context: --
+custom_build_prompt:90> prompt+=''
+custom_build_prompt:94> prompt+=+custom_build_prompt:94> enrich_append true '(class-overview  origin)' '%K{red}%F{black}'
+enrich_append:1> local 'flag=true'
+enrich_append:2> local 'symbol=(class-overview'  'origin)'
enrich_append:local:2: not valid in this context: 
tsabran commented 8 years ago

Hello, I had the same issue error, zsh complaining with:

local:2: not valid in this context

This is indeed caused by the following line of enrich_append:

local symbol=$2

By checking on the Internet, I found out that adding double-quotes solved the issue. Yet I don't understand clearly why zsh is complaining without those.

Anyway, using the following did the trick:

local symbol="$2"

isacagou commented 8 years ago

This tip does not work for me. Environment :

capture d ecran 2016-06-23 a 14 46 52
amitmisra16 commented 7 years ago

Same here, this tip did not work for me.

local sysmbol="$2"

Here is my system details:

This behavior is consistent irrespective whether the project is github project cloned and also on gitlab projects (used in my organization) cloned on my local system

+custom_build_prompt:77> local 'type_of_upstream=' +custom_build_prompt:80> [[ false == true ]] +custom_build_prompt:83> [[ 0 -gt 0 ]] +custom_build_prompt:86> [[ 0 -gt 0 ]] +custom_build_prompt:89> [[ 0 == 0 && 0 == 0 ]] +custom_build_prompt:90> prompt+=+custom_build_prompt:90> enrich_append true ' -- -- ' '%K{red}%F{black}' +enrich_append:1> local 'flag=true' +enrich_append:2> local 'symbol=' -- -- enrich_append:local:2: not valid in this context: -- +custom_build_prompt:90> prompt+='' +custom_build_prompt:94> prompt+=+custom_build_prompt:94> enrich_append true '(master  origin)' '%K{red}%F{black}' +enrich_append:1> local 'flag=true' +enrich_append:2> local 'symbol=(master'  'origin)' enrich_append:local:2: not valid in this context:  +custom_build_prompt:94> prompt+=''

Any help in resolving this issue is highly appreciated