Обсуждение: need help with csh

Поиск
Список
Период
Сортировка

need help with csh

От
"Thomas G. Lockhart"
Дата:
I'm trying to fix up initlocation to accept an environment variable as
an input parameter (in addition to the absolute path name it already
accepts).

I'd like to be able to say:

  setenv PGDATA2 /home/postgres/data
  initlocation PGDATA2

However, initlocation sets a local variable PGALTDIR to the input
argument as the program starts, and I'm fumbling around trying to
evaluate the contents of PGALTDIR as an environment variable.

(So, I need PGALTDIR -> PGDATA2 -> /home/postgres/data, and to assign
the path name back to a local variable.)

Anyone know how to do this? Please??

TIA

                   - Tom

Re: [HACKERS] need help with csh

От
Michael Meskes
Дата:
On Sat, Oct 03, 1998 at 06:58:04PM +0000, Thomas G. Lockhart wrote:
> I'm trying to fix up initlocation to accept an environment variable as
> an input parameter (in addition to the absolute path name it already
> accepts).

And how shall it dsitinguish between a path and a variable?

> I'd like to be able to say:
>
>   setenv PGDATA2 /home/postgres/data
>   initlocation PGDATA2

But this could mean the path PGDATA2 too, couldn't it?

> Anyone know how to do this? Please??

I don't even know if it's at all possible.

Michael
--
Dr. Michael Meskes      | Th.-Heuss-Str. 61, D-41812 Erkelenz | Go SF49ers!
Senior-Consultant       | business: Michael.Meskes@mummert.de | Go Rhein Fire!
Mummert+Partner         | private: Michael.Meskes@usa.net     | Use Debian
Unternehmensberatung AG |          Michael.Meskes@gmx.net     | GNU/Linux!

Re: [HACKERS] need help with csh

От
prlw1@cam.ac.uk (Patrick Welche)
Дата:
Michael Meskes wrote:
>
> On Sat, Oct 03, 1998 at 06:58:04PM +0000, Thomas G. Lockhart wrote:
> > I'm trying to fix up initlocation to accept an environment variable as
> > an input parameter (in addition to the absolute path name it already
> > accepts).
>
> And how shall it dsitinguish between a path and a variable?
>
> > I'd like to be able to say:
> >
> >   setenv PGDATA2 /home/postgres/data
> >   initlocation PGDATA2
>
> But this could mean the path PGDATA2 too, couldn't it?

initlocation $PGDATA2

?

Re: [HACKERS] need help with csh

От
"Thomas G. Lockhart"
Дата:
Patrick Welche wrote:
>
> > And how shall it dsitinguish between a path and a variable?
> > >   setenv PGDATA2 /home/postgres/data
> > >   initlocation PGDATA2
> > And how shall it distinguish between a path and a variable?
> > But this could mean the path PGDATA2 too, couldn't it?

I test that the argument, when translated, has a non-empty result. If it
doesn't, I assume that it is an actual path.

> initlocation $PGDATA2

Yes, that's how it has always worked. I wanted it to also function
correctly when invoked with the environment variable as an argument (if
someone forgets to put in the "dollar sign").

I have a working version committed to the cvs tree which uses printenv
to extract the contents of the argument. It correctly distinguishes
between paths and envars, and does the right thing with both.

I'd appreciate any reports of problems on any platforms or environments.
Thanks all for the tips.

                  - Tom