Re: pg_ctl failure with older Bourne shells (use ${1:+"$@"})

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pg_ctl failure with older Bourne shells (use ${1:+"$@"})
Дата
Msg-id 12720.1027089476@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pg_ctl failure with older Bourne shells (use ${1:+"$@"})  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: pg_ctl failure with older Bourne shells (use ${1:+"$@"})  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-bugs
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Yes, I have seen this fix before.  Are people still using shells that
> don't handle "$@" properly?  I guess so or you wouldn't have reported
> it.

I remember having submitted just such a patch a few years ago (for a
different one of our scripts of course) when I was still using HPUX 9.
I'm not sure if later HPUXen have better shells.  Plain /bin/sh on this
platform is ancient.

> We only use "$@" in a few places so I am applying this patch.

Could you check for other scripts where the same thing may have snuck
in?

BTW, O'Reilly's "Unix Power Tools" recommends
    ${1+"$@"}
as the most portable replacement for "$@".  Mike's version has :+
which is not the same.  My man page for the Bourne shell says

     ${parameter:+word}
                    If parameter is set and is non-null, substitute word;
                    otherwise substitute nothing.

     ...

     If the colon (:) is omitted from the above expressions, the shell only
     checks whether parameter is set or not.

It looks to me like the book's method is more correct --- it won't mess
up in the case where $1 has been explicitly given as "".

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: initdb problem
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: pg_ctl failure with older Bourne shells (use ${1:+"$@"})