Subject: Re: [RFC PATCH 09/19] completion: platform-specific helper function to get physical path

From: Johannes Sixt <[email-masked]>
Date: Wed, 09 May 2012 09:37:43 +0200

Am 5/9/2012 2:44, schrieb SZEDER Gábor:
> I'm not sure how to check for MinGW; I just looked through the output from
> 'set', and saw OSTYPE=msys there.

Ususally, we check uname -s for *MINGW* for "portability", but
since a subshell is counter-productive and we are sure that we have a
bash here, I think your check is OK.

> +# __git_pwd_p() stores the physical path of the current working directory
> +# in the variable whose name is given as argument
> +if [ ${OSTYPE-} = "msys" ]; then
> +__git_pwd_p ()
> +{
> +	eval $1="$PWD"
> +}
> +else
> +__git_pwd_p ()
> +{
> +	eval $1=\"$(pwd -P)\"
> +}
> +fi
> +

The following fixup of the quoting is needed at any rate to make the
eval'd commands resistent against directory names with blanks and
double-quotes.

--- >8 ---
From: Johannes Sixt <[email-masked]>
Subject: [PATCH] fixup! completion: platform-specific helper function to get
 physical path

Signed-off-by: Johannes Sixt <[email-masked]>
---
 contrib/completion/git-completion.bash |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index bd7d39e..2cab4a0 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -75,12 +75,12 @@ esac
 if [ ${OSTYPE-} = "msys" ]; then
 __git_pwd_p ()
 {
-	eval $1="$PWD"
+	eval "$1=\$PWD"
 }
 else
 __git_pwd_p ()
 {
-	eval $1=\"$(pwd -P)\"
+	eval "$1=\$(pwd -P)"
 }
 fi
 
-- 
1.7.10.1.1689.gacdfbde