From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Cc: Marco Hinz <mh.codebro@gmail.com>
Subject: [PATCH] Fix VCS_INFO_reposub's command expansion
Date: Mon, 29 Sep 2014 14:23:28 +0200 [thread overview]
Message-ID: <1411993408-31305-1-git-send-email-ft@bewatermyfriend.org> (raw)
In-Reply-To: <20140928171033.GA11234@cheyenne>
Reported-by: Marco Hinz <mh.codebro@gmail.com>
---
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
next prev parent reply other threads:[~2014-09-29 12:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-28 17:10 [patch] Fix VCS_INFO_reposub's whitespace handling Marco Hinz
2014-09-28 17:39 ` Peter Stephenson
2014-09-28 18:52 ` Bart Schaefer
2014-09-29 12:23 ` Frank Terbeck [this message]
2014-09-29 13:26 ` [PATCH] Fix VCS_INFO_reposub's command expansion Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411993408-31305-1-git-send-email-ft@bewatermyfriend.org \
--to=ft@bewatermyfriend.org \
--cc=mh.codebro@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).