[pacman-dev] [PATCH 1/2] Changing [ to [[ and ((

Isaac Good pacman at isaac.otherinbox.com
Thu Nov 12 17:02:21 EST 2009


On Thu, Nov 12, 2009 at 07:16:41PM +0000, Cedric Staniewski wrote:
> > @@ -450,12 +450,12 @@ download_sources() {
> >  	for netfile in "${source[@]}"; do
> >  		local file=$(get_filename "$netfile")
> >  		local url=$(get_url "$netfile")
> > -		if [ -f "$startdir/$file" ]; then
> > +		if [[ -f "$startdir/$file" ]]; then
> >  			msg2 "$(gettext "Found %s in build dir")" "$file"
> >  			rm -f "$srcdir/$file"
> >  			ln -s "$startdir/$file" "$srcdir/"
> >  			continue
> > -		elif [ -f "$SRCDEST/$file" ]; then
> > +		elif [[ -f "$SRCDEST/$file" ]]; then
> >  			msg2 "$(gettext "Using cached copy of %s")" "$file"
> >  			rm -f "$srcdir/$file"
> >  			ln -s "$SRCDEST/$file" "$srcdir/"

What about something like this?
> if [[ "$(check_option makeflags)" = "n" ]]; then

None of the quotes are needed. I'm inclined to replace it with:
> if [[ $(check_option makeflags) = "n" ]]; then

While the quotes around n are not needed, they highlight that n is a string which appeals to me since it looks like a string as found in other languages. Or would you say to drop all the quotes.

Maybe some style guidelines are needed for the bash language...

 - Isaac


More information about the pacman-dev mailing list