Re: When scripting, which is better? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: When scripting, which is better?
Date
Msg-id 200110011646.f91GkWP05617@candle.pha.pa.us
Whole thread Raw
In response to When scripting, which is better?  (Justin Clift <justin@postgresql.org>)
List pgsql-hackers
> Hi all,
> 
> Reading through the script files again, there seems to be several
> different methods of doing the same thing :
> 
> i.e.  if [ -x "$self_path/postmaster" ] && [ -x "$self_path/psql" ];
> then

The above semicolon is useless.  Actually, I have never see this.  The
normal way is:
if [ -x "$self_path/postmaster" -a -x "$self_path/psql" ]

> 
> or
> 
> if [[ -x "$self_path/postmaster" && -x "$self_path/psql" ]]; then


I usually do:
if [ ... ]then

Pretty simple.

> 
> 
> 
> 
> if [ x"$foo" = x"" ]; then
> 
> or
> 
> if [ "$op" = "" ]; then

This is done if you think $op may have a leading dash.

> 
> or
> 
> if [ "$foo" ]; then
> 

This tests whether "$foo" is not equal to "".


--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Vince Vielhaber
Date:
Subject: Re: developer's faq
Next
From: Dave Page
Date:
Subject: Re: [ODBC] UTF-8 support