From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26960 invoked by alias); 29 Sep 2014 12:29:21 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33277 Received: (qmail 21654 invoked from network); 29 Sep 2014 12:29:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 From: Frank Terbeck To: zsh-workers@zsh.org Cc: Marco Hinz Subject: [PATCH] Fix VCS_INFO_reposub's command expansion Date: Mon, 29 Sep 2014 14:23:28 +0200 Message-Id: <1411993408-31305-1-git-send-email-ft@bewatermyfriend.org> X-Mailer: git-send-email 2.1.0.60.g85f0837 In-Reply-To: <20140928171033.GA11234@cheyenne> References: <20140928171033.GA11234@cheyenne> X-Df-Sender: NDMwNDQ0 Reported-by: Marco Hinz --- The problem, as others mentioned, is that $(...) is subject to word-splitting. I think we should fix it like is done below. Even though in a variable assignment: foo=$(...) There is *no* word-splitting, I think the use of the double quotes is warranted, since it underlines the intend. Also, using a temporary variable like this should save a stat() call. Functions/VCS_Info/VCS_INFO_reposub | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Functions/VCS_Info/VCS_INFO_reposub b/Functions/VCS_Info/VCS_INFO_reposub index 1c16f0e..8ebc90b 100644 --- a/Functions/VCS_Info/VCS_INFO_reposub +++ b/Functions/VCS_Info/VCS_INFO_reposub @@ -3,11 +3,12 @@ ## Distributed under the same BSD-ish license as zsh itself. setopt localoptions extendedglob NO_shwordsplit -local base=${1%%/##} +local base=${1%%/##} tmp -[[ $(pwd -P) == ${base}/* ]] || { +tmp="$(pwd -P)" +[[ $tmp == ${base}/* ]] || { printf '.' return 1 } -printf '%s' ${$(pwd -P)#$base/} +printf '%s' ${tmp#$base/} return 0 -- 2.1.0.60.g85f0837