[Rear-users] bash style
schlomo at schapiro.org
Tue Jun 21 18:37:46 CEST 2011
congratulations, you convinced me!
Am 19.06.2011 13:48, schrieb Dag Wieers:
> 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.
sschapiro at dev4003:~$ time for (( k=1 ; k<1000000 ; k++ )) ; do [ $k -gt
500 ] ; done
sschapiro at dev4003:~$ time for (( k=1 ; k<1000000 ; k++ )) ; do [[ $k -gt
500 ]] ; done
sschapiro at dev4003:~$ time for (( k=1 ; k<1000000 ; k++ )) ; do (( k >
500 )) ; done
I actually was surprised...
> 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.
Yes, definitively. Thanks a lot for providing these links.
>> 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
OK, I am also ready to go with this. With vim I actually have one
remaining problem: When I paste somthing indented with the mouse lines
get stupidly indented and look like a staircase. Apparently when pasting
with the mouse each indent adds up to the previous indent. Any ideas?
> Tabs vs spaces is a discussion that's as old as computers.
I know and thanks for providing these links, they helped.
PS: Feel free to commit your long-waiting convert-all-tab-to-spaces
More information about the rear-users