Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix VCS_INFO_reposub's command expansion
- X-seq: zsh-workers 33277
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Fix VCS_INFO_reposub's command expansion
- Date: Mon, 29 Sep 2014 14:23:28 +0200
- Cc: Marco Hinz <mh.codebro@xxxxxxxxx>
- In-reply-to: <20140928171033.GA11234@cheyenne>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20140928171033.GA11234@cheyenne>
Reported-by: Marco Hinz <mh.codebro@xxxxxxxxx>
---
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author