Skip site navigation (1) Skip section navigation (2)

Re: When scripting, which is better?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Justin Clift <justin(at)postgresql(dot)org>
Cc: PostgreSQL Hackers Mailing List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: When scripting, which is better?
Date: 2001-10-01 16:46:32
Message-ID: 200110011646.f91GkWP05617@candle.pha.pa.us (view raw or flat)
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2001-10-01 16:51:09
Subject: Re: developer's faq
Previous:From: Vince VielhaberDate: 2001-10-01 16:40:33
Subject: Re: developer's faq

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group