Re: Bash style of if-then-else?

2010-09-24 Thread Michael Witten
On Fri, Sep 24, 2010 at 03:22, Marc Herbert marc.herb...@gmail.com wrote: On Thu, Sep 23, 2010 at 04:38:42PM -0500, Michael Witten wrote: This is also possible: [ -f $file ] do_something Note that this style is not compatible with set -e I was going to note that same caveat in my

Re: Bash style of if-then-else?

2010-09-23 Thread Ken Irving
On Thu, Sep 23, 2010 at 04:38:42PM -0500, Michael Witten wrote: On Mon, Aug 23, 2010 at 16:40, Eric Blake ebl...@redhat.com wrote: On 08/23/2010 03:29 PM, Peng Yu wrote: Hi, I'm wondering if there is a widely accepted coding style of bash scripts.

Re: Bash style of if-then-else?

2010-08-24 Thread Chris F.A. Johnson
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

Re: Bash style of if-then-else?

2010-08-24 Thread Joachim Schmitz
Chris F.A. Johnson wrote: 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

Re: Bash style of if-then-else?

2010-08-24 Thread Pierre Gaston
On Tue, Aug 24, 2010 at 10:25 AM, Joachim Schmitz nospam.j...@schmitz-digital.de wrote: Chris F.A. Johnson wrote: 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

Re: Bash style of if-then-else?

2010-08-24 Thread Joachim Schmitz
Pierre Gaston wrote: On Tue, Aug 24, 2010 at 10:25 AM, Joachim Schmitz nospam.j...@schmitz-digital.de wrote: Chris F.A. Johnson wrote: 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

Bash style of if-then-else?

2010-08-23 Thread Peng Yu
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,

Re: Bash style of if-then-else?

2010-08-23 Thread Eric Blake
On 08/23/2010 03:29 PM, Peng Yu 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

Re: Bash style of if-then-else?

2010-08-23 Thread Dennis Williamson
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