perf(fish): migrate FORGIT_ vars without spawning subprocesses

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: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
AllanZyne 2026-07-07 03:48:01 +02:00
parent e0c7b844b5
commit f14717983e

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:"