[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash style of if-then-else?
From: |
Chris F.A. Johnson |
Subject: |
Re: Bash style of if-then-else? |
Date: |
Tue, 24 Aug 2010 02:42:48 -0400 (EDT) |
User-agent: |
Alpine 2.00 (LMD 1167 2008-08-23) |
On Mon, 23 Aug 2010, Dennis Williamson wrote:
If you're writing a Bash-specific script then it's preferable to use
double square brackets (see http://mywiki.wooledge.org/BashFAQ/031).
if [[ -f $file ]]
then
do something
fi
I'd avoid non-portable syntax unless it offers a significant
advantage over standard syntax.
[[ ... ]] is not standard, and offers little over the standard
syntax.
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)