ParamStr(0) bug??

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ParamStr(0) bug??

Bob Richards-2
I have written a program who's behavior depends on the name by which it has been invoked.
This is not uncommon, for instance sendmail invoked as mailq behaves in a completely
different way.

Anyway, it all works as intended as long as I *copy* the executable to a different name.
However, if I use a symlink, the ParamStr(0) function doesn't work as I would expect. It
always returns the name of the executable not the name of the link to it.

Example:


Program test;

Begin
  WriteLn('This program was executed as: ',ParamStr(0));

end.

----

$ ./test
This program was executed as: /home/bob/pascal/test/test

cp test test1
./test1
This program was executed as: /home/bob/pascal/test/test1
$


$ ln -s test test1
$ ./test1
This program was executed as: /home/bob/pascal/test/test
$

-----

Is there a way to make this work properly? Another method? Is this a bug?

Bob


--
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: ParamStr(0) bug??

John Coppens
On Mon, 24 Apr 2006 13:35:40 -0400
Bob Richards <[hidden email]> wrote:

> I have written a program who's behavior depends on the name by which it
> has been invoked. This is not uncommon, for instance sendmail invoked
> as mailq behaves in a completely different way.

You could try to access the environment variables - the '_' variable
contains the command used to start the program. Just tested it - it shows
the link.

John
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: ParamStr(0) bug??

Bob Richards-2
John Coppens wrote:

> You could try to access the environment variables - the '_' variable
> contains the command used to start the program. Just tested it - it shows
> the link.

Thanks John! That works a charm.

--
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal