perf(fish): migrate FORGIT_ vars without spawning subprocesses (#543)

The backwards-compatibility block that exports unexported FORGIT_ config
variables ran `set | awk | grep` plus a `set -x | grep` for every variable,
forking multiple external processes on every interactive fish startup.

Replace the pipeline with fish's built-in `set -n`/`set -xn` and
`string match`, which run in-process. Behavior is unchanged: unexported
FORGIT_ variables are still detected, warned about, and exported; nothing
is emitted when all variables are already exported.

Co-authored-by: AllanZyne <AllanZyne@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Yang Zhao 2026-07-14 03:42:17 +08:00 committed by GitHub
parent a8e9d8bf57
commit 9fa93b0861
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,8 +15,8 @@ end
# backwards compatibility:
# export all user-defined FORGIT variables to make them available in git-forgit
set unexported_vars 0
set | awk -F ' ' '{ print $1 }' | grep FORGIT_ | while read var
if not set -x | grep -q "^$var\b"
for var in (set -n | string match -er '^FORGIT_')
if not set -xn | string match -qr "^$var\$"
if test $unexported_vars = 0
forgit::warn "Config options have to be exported in future versions of forgit."
forgit::warn "Please update your config accordingly:"