From f208e3d44c625878a2fafbf7037ab6350432b83c Mon Sep 17 00:00:00 2001 From: Felix Eckhofer Date: Tue, 16 Jun 2015 01:46:28 +0200 Subject: [PATCH] Speed up `which` by avoiding a loop --- vcsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vcsh b/vcsh index 8bfafab..11370f8 100755 --- a/vcsh +++ b/vcsh @@ -427,9 +427,7 @@ use() { which() { [ -e "$VCSH_COMMAND_PARAMETER" ] || fatal "'$VCSH_COMMAND_PARAMETER' does not exist" 1 for VCSH_REPO_NAME in $(list); do - for VCSH_FILE in $(get_files); do - echo "$VCSH_FILE" | grep -q "$VCSH_COMMAND_PARAMETER" && echo "$VCSH_REPO_NAME: $VCSH_FILE" - done + get_files | grep -- "$VCSH_COMMAND_PARAMETER" | sed "s/^/$VCSH_REPO_NAME: /" done | sort -u } -- 2.39.5