Fix multi selection in gitignore generation

Choose for loop as the solution cause:
- `xargs -d` is not available in BSD xargs
- `echo $@ |tr ' ' '\n'` is slower that for loop in this case


Former-commit-id: 51961b763f
This commit is contained in:
laggardkernel 2019-01-11 16:27:16 +08:00
parent bd2974e397
commit c9869c2167
2 changed files with 6 additions and 2 deletions

View file

@ -159,7 +159,9 @@ __forgit_ignore_update() {
}
__forgit_ignore_get() {
mkdir -p $FORGIT_GI_CACHE
echo $@ |xargs -I{} bash -c "cat $FORGIT_GI_CACHE/{} 2>/dev/null || (curl -sL https://www.gitignore.io/api/{} |tee $FORGIT_GI_CACHE/{})"
for item in "$@"; do
cat "$FORGIT_GI_CACHE/$item" 2>/dev/null || (curl -sL https://www.gitignore.io/api/{} |tee "$FORGIT_GI_CACHE/$item")
done
}
__forgit_ignore_clean() {
[[ -d $FORGIT_GI_CACHE ]] && rm -rf $FORGIT_GI_CACHE

View file

@ -155,7 +155,9 @@ forgit::ignore::update() {
}
forgit::ignore::get() {
mkdir -p $FORGIT_GI_CACHE
echo $@ |xargs -I{} bash -c "cat $FORGIT_GI_CACHE/{} 2>/dev/null || (curl -sL https://www.gitignore.io/api/{} |tee $FORGIT_GI_CACHE/{})"
for item in "$@"; do
cat "$FORGIT_GI_CACHE/$item" 2>/dev/null || (curl -sL https://www.gitignore.io/api/{} |tee "$FORGIT_GI_CACHE/$item")
done
}
forgit::ignore::clean() {
setopt localoptions rmstarsilent