[fpc-pascal] TProcess questions

Adrian Maier adrian.maier at gmail.com
Tue Oct 3 12:06:10 CEST 2006

On 10/3/06, Marco van de Voort <marcov at stack.nl> wrote:
> > On Tue, 3 Oct 2006, Adrian Maier wrote:
> > >
> > > It's a painful one.  I was hoping to switch to TProcess instead of shell (
> > > which isn't  cross-platform )  ...
> >
> > The bug won't occur on windows :)
> >
> > I will see about fixing it. Could you please post a bug report so it won't
> > be forgotten.
> Wouldn't it be better to also have a way to set the parameters using an
> indexed property one by one instead of a cmdline?
> Because this kind of interpretation issues will continue forever, since shell
> handling is not portable. This was
> pretty much the reason for the change to array of string in ExecuteProcess
> and friends.
> In such case, there is always a "safe" fall back.

It seems nice to have a way of specifying parameters like that (in which case
I assume that strings given will be passed as-they-are).

There is one more thing about TProcess  that i've been surprised to
see that after:
all the variables inherited from the parent process are no longer passed to the
external program by TProcess.

The behaviour is documented :
" Environment contains the environment for the new process; it's a
list of Name=Value pairs, one per line. If it is empty, the
environment of the current process is passed on to the new process. "

So, initially the Environment is empty and the program inherits the variables.
When I append the first variable, it will no longer inherit the variables.

I find the behaviour counterintuitive:  the first "append" causes the
Environment to
be initialised.

I haven't discovered yet how could the programmer preserve the
inherited environment
and only "add" some variables ?

Don't you think that by default the Environment list should be filled
with the current
environment?   This way "append" would mean indeed "append".  It would also
be easy to clear the Environment if needed.

Adrian Maier

More information about the fpc-pascal mailing list