[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Conditional expression evaluation using [ and [[ with -e
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] Conditional expression evaluation using [ and [[ with -eq operator |
Date: |
Fri, 15 Nov 2013 14:46:38 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Fri, Nov 15, 2013 at 05:41:47PM +0000, Peggy Russell wrote:
> declare var='a'
>
> if [ "$var" -eq "$var" ]; then
My personal recommendation would be: don't use -eq, ever. It blows
up if the arguments aren't integers. If they are integers, it acts
just like =. So, there's really no reason not to use = in the first
place.
I consider it one of the things that POSIX and backward compatibilty
require Bash to implement, but which should be considered deprecated
for purposes of writing new scripts.