Re: [PATCH] Update bash completions to prevent unbound variable errors.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux