From 51961b763f1a0dd7359b5965ed766e9d8ba4be88 Mon Sep 17 00:00:00 2001 From: laggardkernel Date: Fri, 11 Jan 2019 16:27:16 +0800 Subject: [PATCH] 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 --- forgit.plugin.sh | 4 +++- forgit.plugin.zsh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/forgit.plugin.sh b/forgit.plugin.sh index 7da37ae..2b2003c 100755 --- a/forgit.plugin.sh +++ b/forgit.plugin.sh @@ -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 diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index bc53dd6..95640b3 100644 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -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