1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

command substitution should be done by compgen

which is much faster.

builtin compgen -W "${list[*]}" -- "${cur}" | sed -r "s@^${colon_word}@@g"
--> 1 minute 20 seconds

builtin compgen -W 'cat ${projects}' -- "${cur}" | sed -r "s@^${colon_word}@@g"
--> 4 seconds
This commit is contained in:
lethliel 2020-02-06 10:44:53 +01:00
parent 0b7b515f11
commit 49c1e9e8ff

11
dist/osc.complete vendored
View File

@ -160,15 +160,14 @@ projects ()
done
shift $argc
cur="$1"
if test -n "${cur}" ; then
list=($(command grep -E "^${cur}" ${projects}))
else
list=($(command cat ${projects}))
fi
if ((colon)) ; then
local colon_word
colon_word=${cur%${cur##*:}}
builtin compgen -W "${list[*]}" -- "${cur}" | sed -r "s@^${colon_word}@@g"
if test -n "${cur}" ; then
builtin compgen -W '`grep -E "^${cur}" ${projects}`' -- "${cur}" | sed -r "s@^${colon_word}@@g"
else
builtin compgen -W '`cat ${projects}`' -- "${cur}" | sed -r "s@^${colon_word}@@g"
fi
else
builtin compgen -W "${list[*]}" -- "${cur}"
fi