wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.32k stars 136 forks source link

Detection of unexported variables is incorrect in fish if the variable has an empty string value #289

Closed IndianBoy42 closed 1 year ago

IndianBoy42 commented 1 year ago

Check list

Environment info

Problem / Steps to reproduce

In my config.fish I have:

set -x FORGIT_FZF_DEFAULT_OPTS "

--ansi
--height='80%'
--bind='alt-k:preview-up,alt-p:preview-up'
--bind='alt-j:preview-down,alt-n:preview-down'
--bind='ctrl-r:toggle-all'
--bind='ctrl-s:toggle-sort'
--bind='?:toggle-preview'
--bind='alt-w:toggle-preview-wrap'
--preview-window='right:60%'
+1

"
set -x FORGIT_GI_REPO_LOCAL ""
set -x FORGIT_GI_REPO_REMOTE "https://github.com/dvcs/gitignore"
set -x FORGIT_GI_TEMPLATES ""

Everytime I open a new fish shell I get

[Warn] Config options have to be exported in future versions of forgit.                                                                                       
[Warn] Please update your config accordingly:

The full message gets cut off by my prompt which is annoying but not forgit's fault.

Doing set -x | grep FORGIT_ I can see all of those variables exported of course, so the question is why set -x | grep -q "^$var " in forgit.plugin.fish seems to fail

It seems to be due to the trailing whitespace in the argument to grep. set -x | grep -q "^$var " fails but set -x | grep -q "^$var"

When the variable's value is an empty string, the output of set -x does not have any trailing whitespace.

Unless there is some reason I am missing, simply removing the trailing whitespace from grep -q "^$var " should work