git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Adeodato Simó" <dato@net.com.org.es>
To: Ted Pavlic <ted@tedpavlic.com>
Cc: "Shawn O. Pearce" <spearce@spearce.org>,
	git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] Update bash completions to prevent unbound variable errors.
Date: Mon, 12 Jan 2009 22:40:52 +0100	[thread overview]
Message-ID: <20090112214052.GB24941@chistera.yi.org> (raw)
In-Reply-To: <496BA0E4.2040607@tedpavlic.com>

* Ted Pavlic [Mon, 12 Jan 2009 14:58:28 -0500]:

I don't know if this patch will go forward or not, but there are several
instances of spurious ${x-}, eg.:

>  __gitdir ()
>  {
> -	if [ -z "$1" ]; then
> +	if [ -z "${1-}" ]; then

Given the above...

> -	elif [ -d "$1/.git" ]; then
> -		echo "$1/.git"
> +	elif [ -d "${1-}/.git" ]; then
> +		echo "${1-}/.git"
>  	else
> -		echo "$1"
> +		echo "${1-}"

... this other hunk is redundant, because if [ -z "${1-}" ] fails, then
$1 is surely set.

>  __git_ps1 ()
>  {
>  	local g="$(git rev-parse --git-dir 2>/dev/null)"
> -	if [ -n "$g" ]; then
> +	if [ -n "${g-}" ]; then

Spurious, $g is always set here.

> @@ -111,8 +111,8 @@ __git_ps1 ()
> -		if [ -n "$1" ]; then
> +		if [ -n "${1-}" ]; then

This one is okay...

> -			printf "$1" "${b##refs/heads/}$r"
> +			printf "${1-}" "${b##refs/heads/}$r"

But this one is unnecessary, if [ -n "${1-}" ] succeeds, then $1 is set.

And so on.

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
The true teacher defends his pupils against his own personal influence.
                -- Amos Bronson Alcott

      parent reply	other threads:[~2009-01-12 21:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-12 19:58 [PATCH] Update bash completions to prevent unbound variable errors Ted Pavlic
2009-01-12 20:35 ` Boyd Stephen Smith Jr.
2009-01-12 20:40   ` Adeodato Simó
2009-01-12 21:27     ` Boyd Stephen Smith Jr.
2009-01-12 21:31       ` Shawn O. Pearce
2009-01-12 21:38         ` Boyd Stephen Smith Jr.
2009-01-12 21:11   ` Ted Pavlic
2009-01-12 21:21     ` Ted Pavlic
2009-01-12 21:32       ` Shawn O. Pearce
2009-01-12 21:51         ` Ted Pavlic
2009-01-12 21:25     ` Adeodato Simó
2009-01-12 21:37       ` Ted Pavlic
2009-01-12 21:47         ` Adeodato Simó
2009-01-12 21:40 ` Adeodato Simó [this message]

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=20090112214052.GB24941@chistera.yi.org \
    --to=dato@net.com.org.es \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    --cc=ted@tedpavlic.com \
    /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.
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).