From: Ted Pavlic Date: Tue, 13 Jan 2009 04:30:16 GMT Subject: Re: [PATCH] Simple update to bash completions to prevent unbound variable errors. Message-ID: <496C18D8.9070707@tedpavlic.com> In-Reply-To: <7vy6xfew2n.fsf@gitster.siamese.dyndns.org> >> A vim modeline has also been added for consistency. > > Yuck. Better that than have a mixture of spaces and tabs. >> +# __git_ps1 accepts 0 or 1 arguments (i.e., format string) >> +# returns text to add to bash PS1 prompt (includes branch name) > > Good. Would be better if you described what $1 and $2 mean. In that case, there's only $1 (the format string). Note that in most cases, I didn't know what $1 and $2 were. I was just trying to fix it so that it would work on my system. >> - if [ -n "$1" ]; then >> + if [ $# -gt 0 ]&& [ -n "$1" ]; then > > I found the previous round's [ -n "${1-}" ] much easier to read, if we were to > do this. If -n "${1-}", then "$1" is definitely set so nothing need to > change in the then ... else part. Hey -- I agree, but no one else liked ${1-}. And hg's bash completion seems far superior because they avoid ever having to worry about it. They actually thought about the arguments ahead of time. >> +# __gitcomp_1 requires 2 arguments > > ... and $1 and $2 mean? No clue. Patches are welcome. > Yuck. If you are taking advantage of the fact that "local one" > will bind one to emptiness anyway, can't you do something like: > > local one=${1-} two=${2-} cur=${3-} four=${4-} Why even use one, two three, and four then? I had ${#-} throughout, but I was told that that was ugly. So the best I could do was come up with the above mess. --Ted -- Ted Pavlic Please visit my ALS association page: http://web.alsa.org/goto/tedpavlic My family appreciates your support in the fight to defeat ALS.