Closed gbtec-markusmeier closed 1 year ago
Forgit detects variables and functions in bash instead of only variables. See: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
Write a function that sets a FORGIT environment variable and then source forgit:
FORGIT
load_forgit() { export FORGIT_PAGER=less source "${HOME}/bin/forgit/forgit.plugin.sh" } load_forgit
[Warn] Config options have to be exported in future versions of forgit. [Warn] Please update your config accordingly: [Warn] export FORGIT_COPY_CMD [Warn] export FORGIT_DIFF_FZF_OPTS [Warn] export FORGIT_LOG_FZF_OPTS [Warn] export FORGIT_PAGER [Warn] export FORGIT_STASH_FZF_OPTS [Warn] export export FORGIT_PAGER bash: export: `export FORGIT_PAGER': not a valid identifier
The test in https://github.com/wfxr/forgit/blob/master/forgit.plugin.zsh#L24 should correctly report only variables, not strings in functions.
Bash's set returns (amongst others) the above defined function:
set
load_forgit () { export FORGIT_PAGER=less; source "${HOME}/bin/forgit/forgit.plugin.sh" }
When grepping the result, line export FORGIT_PAGER=less; is processed.
export FORGIT_PAGER=less;
Detect only variables in bash without functions:
https://unix.stackexchange.com/questions/176001/how-can-i-list-all-shell-variables
Note that set -o posix ; set is only available in bash, not in zsh, so we would need to distinguish that in https://github.com/wfxr/forgit/blob/master/forgit.plugin.zsh#L24
set -o posix ; set
Check list
Environment info
Problem / Steps to reproduce
Problem
Forgit detects variables and functions in bash instead of only variables. See: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
Reproduction
Write a function that sets a
FORGIT
environment variable and then source forgit:Result
Expectation
The test in https://github.com/wfxr/forgit/blob/master/forgit.plugin.zsh#L24 should correctly report only variables, not strings in functions.
Deeper analysis
Bash's
set
returns (amongst others) the above defined function:When grepping the result, line
export FORGIT_PAGER=less;
is processed.Solution
Detect only variables in bash without functions:
https://unix.stackexchange.com/questions/176001/how-can-i-list-all-shell-variables
Note that
set -o posix ; set
is only available in bash, not in zsh, so we would need to distinguish that in https://github.com/wfxr/forgit/blob/master/forgit.plugin.zsh#L24