[Rear-users] bash style

Dag Wieers dag at wieers.com
Sun Jun 19 13:48:12 CEST 2011

On Sun, 19 Jun 2011, Schlomo Schapiro wrote:

> I am really against using [[ ]] in places where it behaves like [ ]. The reason
> for that is that [[ carries the danger of unplanned pattern matches. And [[ code
> && code ]] is not a reason to change [ code -a code ], it adds no benefit and
> even carries the risk of confusing the && within the [[]] with the && that can
> be normally used.

[[ is faster than [ or test. What's more it offers more possibilities 
(like pattern matching) and it supports overriding normal precedence 
(using '( )') which [ or test make this very awkward.

If we are only considering bash programming, it's _the_ choice for doing 
testing (together with arithmetic testing using '(( ))'). Most of the bash 
programming guides actually advise to use [[ ]] and (( )) constructs.


But as always, one needs to know what one is doing.

> Even though it is against my personal taste I am ready to go over that and use [
> over test, IF the majority of the list prefers it that way.
> Also, please use tabs and not spaces.

Once again this is something Jeroen and I see differently, the use of tabs 
is very irritating, especially if you want to do proper and consistent 
indentation. I would advise to use the following vim options:

     set tabstop=4
     set shiftwidth=4
     set expandtab
     set listchars=tab:»·,trail:·
     set list

Especially the list* stuff is very useful to find trailing spaces (lots of 
those in Rear, a lot already cleaned up) and you can see where tabs and 
spaces are used inconsistently. Without the above, you wouldn't even 
notice where things go wrong.

I am not sure why you insist on using of tabs over spaces, but I can 
tell you that tabs are not worth the trouble (don't work in web forms, 
often cannot be copy&pasted properly, doesn't allow exceptional 
indentation, with tabs you can not be sure what the length is for proper 


Tabs vs spaces is a discussion that's as old as computers.

PS I am not sure why you bring up python in this discussion when it was
    mentioned in the past, but python allows both, just as bash and C and
    perl and ...


    Python simply expects you to do it consistently, whatever you prefer.

-- dag wieers, dag at wieers.com, http://dag.wieers.com/
-- dagit linux solutions, info at dagit.net, http://dagit.net/

[Any errors in spelling, tact or fact are transmission errors]

More information about the rear-users mailing list