FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux General Discussion

 
 
LinkBack Thread Tools
 
Old 06-30-2010, 09:47 PM
Victor Lowther
 
Default for conditional checking when running in bash.

It is worth 10 - 30% speedup whenever you want to compare something.
---
functions | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/functions b/functions
index 6df8c5e..9b348b7 100644
--- a/functions
+++ b/functions
@@ -40,7 +40,7 @@ unset TERM_COLORS
unset TZ

# colors:
-if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then
C_MAIN="33[1;37;40m" # main text

C_OTHER="33[1;34;40m" # prefix & brackets
--
1.7.1
 
Old 06-30-2010, 09:56 PM
Thomas Bächler
 
Default for conditional checking when running in bash.

Am 30.06.2010 23:47, schrieb Victor Lowther:
> It is worth 10 - 30% speedup whenever you want to compare something.

Where do you get this from? I always used [ ], and I found it
sufficient. Why is [[ ]] faster?

> -if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
> +if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then

Why do you get rid of the quoting here? Quoting is nice.
 
Old 06-30-2010, 10:01 PM
Daenyth Blank
 
Default for conditional checking when running in bash.

On Wed, Jun 30, 2010 at 17:56, Thomas Bächler <thomas@archlinux.org> wrote:
> Am 30.06.2010 23:47, schrieb Victor Lowther:
>> It is worth 10 - 30% speedup whenever you want to compare something.
>
> Where do you get this from? I always used [ ], and I found it
> sufficient. Why is [[ ]] faster?
>
>> -if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
>> +if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then
>
> Why do you get rid of the quoting here? Quoting is nice.
>
>

Quoting is not needed in [[ and it makes the code uglier.
 

Thread Tools




All times are GMT. The time now is 11:27 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org