[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash style of if-then-else?
From: |
Dennis Williamson |
Subject: |
Re: Bash style of if-then-else? |
Date: |
Mon, 23 Aug 2010 18:17:04 -0500 |
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 prefer forms using the fewest number of semicolons, but I really
don't think it matters. Consistency is more important.
On Mon, Aug 23, 2010 at 4:29 PM, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> I'm wondering if there is a widely accepted coding style of bash scripts.
>
> lug.fh-swf.de/vim/vim-bash/StyleGuideShell.en.pdf
>
> I've seen the following style. Which is one is more widely accepted?
>
> if [ -f $file]; then
> do something
> fi
>
> if [ -f $file];
> then
> do something
> fi
>
> --
> Regards,
> Peng
>
>